DLL INSTANCE = (DLL) Native.loadLibrary(Settings.getSingletonInstance().getProperty("default.ergoPointer.path"), DLL.class);
我将dll路径存储在设置文件中。当我拿出
的输出Settings.getSingletonInstance().getProperty("default.ergoPointer.path"
此处:C:\Users\Argenit\Desktop\aaa\dll\ErgoPointer_64_Bit.dll
错误部分:
java.lang.UnsatisfiedLinkError:无法加载库 ' C:\ Users \ Argenit \ Desktop \ aaa \ dll \ ErgoPointer_64_Bit.dll':Native 图书馆 (Win 32的x86-64的/ C:\用户\ Argenit \桌面\ AAA \ DLL \ ErgoPointer_64_Bit.dll) 在资源路径中找不到 ([文件:/ C:/用户/ Argenit /桌面/ Pathology_JAVA / Digital_Pathology / bin中/, 文件:/ C:/用户/ Argenit /桌面/ Pathology_JAVA / Digital_Pathology /资源/, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/fits.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/json.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/junit-4.8.2.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/kdu_jni.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/log4j-1.2.16.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/JNA/jna-4.1.0.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/JNA/jna-platform-4.1.0.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/ini4j-0.5.4.jar, 文件:/ C:/用户/ Argenit /桌面/ Pathology_JAVA / Digital_Pathology / JNA /, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/gluegen-rt.jar, 文件:/ C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/jogl.jar])
如果我在项目中添加(dll)作为外部类文件夹并写入:loadLibrary("ErgoPointer_64_Bit")
,它可以在这台机器上工作,但是当我拿到可运行的jar时,它就无法运行。找到ErgoPointer_64_Bit
所以我想给出dll的绝对路径。但它没有'为我工作。
我也尝试过:
C:\用户\ Argenit \桌面\ AAA \ DLL \ ErgoPointer_64_Bit
DLL \ ErgoPointer_64_Bit
ErgoPointer_64_Bit
DLL \ ErgoPointer_64_Bit.dll
ErgoPointer_64_Bit.dll
答案 0 :(得分:2)
在使用基本名称调用Native.loadLibrary()之前设置系统属性java.library.path。
System.setProperty("java.library.path",
"C:\\Users\\Argenit\\Desktop\\aaa\\dll;"
+ System.getProperty("java.library.path"));
DLL INSTANCE = (DLL) Native.loadLibrary("ErgoPointer_64_Bit", DLL.class);
您还可以在命令行上设置java.library.path。例如
java "-Djava.library.path=C:\Users\Argenit\Desktop\aaa\dll\" -jar somejar.jar