I want to use this jar file (http://sourceforge.net/projects/uirt-j/) in a personal project. Currently, I’ve been using Eclipse and tried to import that jar (Project > Java Build Path > Add External JARs).
After importing it, I can see all classes from that package listed in Eclipse, however, this jar also contains two win32 dll files, needed to communicate to the device. I’ve tried to add them to System32 dir, but no luck. When I run this project, it throws the following exception:
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 the dlls are correctly linked and they can be imported.
Code snippet:
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 that JAR file is executed standalone, it works fine. My current setup runs under Windows 7 64bits.
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 platformor similar.Try copying the dlls into
C:\Windows\SysWOW64rather thanC:\Windows\System32. 32 bits dlls should go intoC:\Windows\SysWOW64. It worked for me, although I gotutil.USBUIRT$NotInitializedExceptionwhich is probably the indication the libraries were loaded properly.File System Redirector article may shed some light on
SysWOW64vsSystem32.EDIT: tweaking java.library.path
You may also go with a solution mentioned in comments, for example, copy dlls into
C:\tmpand run with argument:But since there is a dependency between the two dlls,
C:\tmpmust be onPATH. Otherwise there is stillUnsatisfiedLinkError. Manually loadinguuirtdrv.dllshould help, ie: