UnsatisfiedLinkError: Can't find dependent libraries
SreramDec 5 2011 — edited Dec 26 2011
Am currently developing an application based on JNI. I have, after linking required libraries in c and compiling it, created a dll file 'hidapi.dll', which i load in java program via System.loadLibrary("hidapi") and compile it. When i run it in my machine (after of course, putting the dll file in System32 folder - Am using Wn 7 for your info.. ), the code runs perfectly fine. So far so good.
But when i put the dll file in another machine the dll file is not getting loaded... My code gives an exception java.lang.UnsatisfiedLinkError: C:\Windows\System32\hidapi.dll: Can't find dependent libraries... When i tried to have the verbose messages through -verbose:jni , I get the following message.
[Dynamic-linking native method java.io.FileOutputStream.writeBytes ... JNI]
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Window
s\System32\hidapi.dll: Can't find dependent libraries
[Dynamic-linking native method java.lang.Throwable.getStackTraceDepth ... JNI]
[Dynamic-linking native method java.lang.Throwable.getStackTraceElement ... JNI]
at java.lang.ClassLoader$NativeLibrary.load(Native Method)[Dynamic-linking native method sun.awt.windows.WComponentPeer.nativeHandleEvent ... JNI]
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)
hidsignalapi.UsbPctoolJni is the class where i load the dll file, and line 46 is exactly the line where i wrote 'System.loadLibrary("hidapi");'
I saw in a few forums to ensure the class names are correct... But if that is the case, it must not run in my system too right? The only linked files are jni.h and a custom library hidapi.h. Should the hidapi.h too must be put in classpath? Has any body has any idea about this..?