我知道我必须将我的库存储到 java.library.path 文件夹中。我将我的 dll 放在 c:\windows\system32 文件夹中(我使用的是 32 位 jre)并尝试了以下代码:
public static void main(String[] args) {
System.out.println(System.getProperty("java.library.path"));
System.loadLibrary("ZebraNativeUsbAdapter_32");
}
我得到了这个输出:
C:\Program Files (x86)\Java\jre1.8.0_73\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\ javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX \Common;D:\Programmi\Skype\Phone\;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files\MariaDB 10.1\bin;。
而这个错误:
线程“主”java.lang.UnsatisfiedLinkError 中的异常:java.library.path 中没有 ZebraNativeUsbAdapter_32
然后我尝试将 dll 文件放入 C:\Program Files (x86)\Java\jre1.8.0_73\bin 并且它可以工作!但是为什么这两个文件夹都列在 java.library.path 中但只有其中一个有效?