Search code examples
javadlljava-native-interface

Provide DLL path to System.loadLibrary on export


I want to export my Java application which uses JNI interface, and loads a DLL via System.loadLibrary("dllName").

The DLL file is present inside Java Project folder as well as in C drive, one of places where JVM will search for DLL at runtime.

Problem: When I export this project out as a Jar and give it to client, client should be able to run the tool without hassles of entering a Dll file. I can't think of accomplishing this via alternative way; to provide absolute path by using System.load("path:\\") because I don't know where the user would download the Jar file to.


Solution

  • You need to put the DLL in the same path that the application is running, in a system path or add its path the PATH variable before starting the app.