无法在Java代码中使用.dll文件 [英] unable to use .dll file in the Java code
问题描述
可能重复:
如何在java代码中使用.dll文件?
我正在使用的dll文件发出错误:
The dll file, I am using, is giving error:
错误信息是:
java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: Eagleye_parser
at java.lang.Runtime.load0(Runtime.java:767)
at java.lang.System.load(System.java:1005)
at test.TestDllJava.<clinit>(TestDllJava.java:15)
Exception in thread "main"
这是代码:
public class TestDllJava {
private static native String[] eagleye_fmu(String A);
public static void main(String[] args){
String[] ag = null;
String parameter = null;
parameter = "356188030442449 10250000 0001F464 0000EB34 0002CC7D 4xA0";
ag = eagleye_fmu(parameter);
System.out.println(ag);
}
static {
System.load("Eagleye_parser");
}
}
请更正我,我做错了什么/ p>
Please correct me, where I am doing wrong.
推荐答案
作为 docs of load()指定:
将本地文件
系统中的指定文件名的代码文件作为动态库加载。 文件名参数必须是一个完整的
路径名。
图书馆的绝对路径是使用 loadLibrary()或者可能 load(
mapLibraryName(..)
。
A better approach without stating an absolute path to library is by using loadLibrary() or maybe load(
mapLibraryName(..)
)
.
在Eclipse中,您可以通过项目属性 - > Java构建路径在项目中指定本机库文件夹 - >选项卡库 - >展开系统库,单击本地库位置。 Eclipse将为您构建 java.library.path
,然后轻松查看 loadLibrary()
。
In Eclipse, you can specify native library folder in your project via project Properties -> Java build Path -> tab Libraries -> expand your System Library, click Native Library Location. Eclipse will build java.library.path
for you and loadLibrary()
will then see it easily.
这篇关于无法在Java代码中使用.dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!