Long story short: I have an executable jar, that calls jni.dll
which is dependent on lib.dll
. And I\'m getting the oh-so-dreaded UnsatisfiedL
If the problem is that the os can not find the dependency library, have you tried loading it via System.loadLibrary()
before you load your main library?
java.library.path
specifies the directories where System.loadLibrary()
looks for the dynamic library file. If you change the java.library.path
system property in your code, it will not have any effect. There are hacks to make Java "forget" the initial value and re-evaluate the contents of the java.library.path
system property.
However, the dependent library is not loaded by Java, it's loaded by Windows. Windows does not care about java.library.path
, it only cares about the PATH
environment variable. Your only option is to adjust PATH
for your Java process. For example, if you start it from a batch file, change the PATH
environment variable right before the java invocation.
The simplest solution is to ensure that all .dlls are in '.' when you execute.
Put dlls your jni.dll depends on in your "current working directory", check this System.getProperty("user.dir")
at runtime to get to know what is your "current working directory"