Java JNI and dependent libraries on Windows

前端 未结 4 1938
挽巷
挽巷 2020-12-09 20:47

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

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 20:56

    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.

提交回复
热议问题