I have a system where I have 1 .exe file, 4 .dll files and one jar file where the dependencies are as shown below:
A.exe -> calls -> B.dll -> calls through JNI -> C.jar -> loads with System.loadLibrary("") -> D.dll -> calls E.dll
Now, B through E is one module and all those files are in the same directory. A.exe is an application placed in a different directory which can use several of these modules.
My main problem is that when D.dll tries to load E.dll I get a 'Can't find dependent libraries' java.lang.UnsatisfiedLinkError. If I am standing in the module directory and run C.jar manually there is no such error and D.dll manages to load E.dll just fine.
So, my main question here is: AddDllDirectory(%moduleDir%) is run in A.exe, but how far does it actually get 'inherited'? Does C.jar somehow remove the directory added by this function? Is there a way to expand the dll search path from java, before the System.loadLibrary("") call, such that the loaded .dll inherits this search path?
- The java.library.path is set to the module directory when B.dll starts the JVM through JNI
- I want to avoid having A.exe altering the PATH environment variable
- No changes should be necessary in D.dll or E.dll
Thanks in advance for any answers
java.lang.UnsatisfiedLinkErrorwhen your system libraryD.dlltries to load the system libraryE.dll. What's the wording of the exception message? Is itD.dll: %1 is not a valid Win32 applicationorno D in java.library.path?java.lang.UnsatisfiedLinkError: <moduleDir>\D.dll: Can't find dependent librariesWhat happens here is that in java whenSystem.loadLibrary("D.dll")is executed, it fails because it cannot find E.dll which D.dll depends on