I have an application which uses methods in a .jar which calls a .dll. This works fine for me on my machine (when the app is unpackaged or run as a .jar itself) but when the application.jar is run on another machine, with the external .dll on the system path, it cannot run the dll file.
Does the .dll have to be located anywhere special? I has assumed that as it was on the system path that it would be found.
Thanks in advance
Dougie
java.library.path solution isn't always good: there are many situations where you can't change JVM parameters. Better solutions:
1) already mentioned: put DLL in the same directory as JAR, unfortunately it makes usage of such a JAR harder - now the JAR isn't just a JAR, but has an accompanying DLL
2) put the DLL into the JAR as a normal resource, during JAR startup extract this DLL somewhere to e.g. $TMP, and then use System.load(new File(...)) as above. Then this JAR is just a JAR, users of this JAR may even don't know that it uses any DLLs
You can also use Maven NAR plugin, which is quite powerful if you're usin Maven for builds. See http://duns.github.com/maven-nar-plugin/
Try to use:
File dll = new File([...]);
System.load(dll.getAbsolutPath());
I would package the dll in the same directory as your jar-archive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With