I want to use this JAR file (http://sourceforge.net/projects/uirt-j/) in my project. In Eclipse I used th option Project > Java Build Path > Add External JARs to import it. I can see all classes of JAR file in Ecplise. This JAR contains two dll files. In order to load dlls, I put into System32 dir, but when a execute my code, a I get the follow error:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Windows\System32\util_USBUIRT.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at util.USBUIRT.<clinit>(USBUIRT.java:269)
at Uirt.main(Uirt.java:6)
Using Dependence Walker I can see that all DLLs are in System32 folder. My Code:
import util.USBUIRT;
public class Uirt {
public static void main(String[] args) {
String code = "0000";
try {
USBUIRT.transmitIR(code, 2, 3, 2);
} catch (Exception e) {
e.printStackTrace();
}
}
}
If JAR is executed alone, that works fine. Thanks. (Windows 7x64)
The dlls in the mentioned jar are 32 bit. The environment is Win7 x64. I assume the JVM is 32 bit otherwise there would be another error, ie: Can't load IA 32-bit .dll on a AMD 64-bit platform or similar.
Try copying the dlls into C:\Windows\SysWOW64 rather than C:\Windows\System32. 32 bits dlls should go into C:\Windows\SysWOW64. It worked for me, although I got util.USBUIRT$NotInitializedException which is probably the indication the libraries were loaded properly.
File System Redirector article may shed some light on SysWOW64 vs System32.
EDIT: tweaking java.library.path
You may also go with a solution mentioned in comments, for example, copy dlls into C:\tmp and run with argument:
-Djava.library.path="C:\tmp;${env_var:PATH}"
But since there is a dependency between the two dlls, C:\tmp must be on PATH. Otherwise there is still UnsatisfiedLinkError. Manually loading uuirtdrv.dll should help, ie:
import util.USBUIRT;
public class Uirt {
static {
System.loadLibrary("uuirtdrv");
}
public static void main(String[] args) {
String code = "0000";
try {
USBUIRT.transmitIR(code, 2, 3, 2);
} catch (Exception e) {
e.printStackTrace();
}
}
}
来源:https://stackoverflow.com/questions/12078457/java-util-usbuirt-dll-cant-find-dependent-libraries