JNI dependent libraries
This helped me a lot. Also managed loading a JNI dll built using cygwin:
first:
/* conditioned if OS is windows because also need it to work in Linux env. */
System.loadLibrary("cygwin1");
then:
System.loadLibrary("mylib");
On windows, This requires either setting the java.library.path to match both libraries locations.
If runnning from Eclipse, this setting may be replaced by "Native Libraries Location" in java build path (in JRE libraries settings).
However, still finding this a bit tricky.
- If you have a DLL name 'MyNativeDLL.dll' then you should use 'MyNativeDLL' in your LoadLibrary call.
- Use Dependency Walker to check if there are any files required by MyNativeDLL.dll
- If there are, include them in the same folder as MyNativeDLL.dll - one you get it working try putting the additional required files in System32 folder.
I was able to get this to work without putting any DLLs on the PATH by using System.load() on all DLLs in reverse dependency order. Just to be clear, I was calling System.load() on all dependent DLLs, not just JNI DLLs. You don't have to call System.load() on DLLs that come with Windows (they're on the PATH).
I was doing this in a web app where a jar included DLLs that were getting unpacked. Your situation seems simpler, so I believe it should work. I generally followed the solution here: How to make a JAR file that includes DLL files?