Search code examples
javaeclipsedlljna

UnsatisfiedLinkError exporting a dll for deployment


I am trying to build a Runnable Jar file from my project, but two lines of code are causing problems.

Inside my project I use JNA to make some function calls to a .dll file which I made, but I cannot link it properly.

I can build and run the application in eclipse no problem, I can also create a runnable jar, but when I try and run it I get this error:

UnsatisfiedLinkError: no kl in java.library.path

kl is the name of my .dll file.

Here is how I am loading it in:

private Dll dll; 

System.loadLibrary("kl");
dll = (Dll) Native.loadLibrary("kl", Dll.class);

The .dll file is currently placed in the root directory of my project. I figure it's the System.loadLibrary that is causing most problems, I need it to look In the main root folder, regardless of who is running my jar file.

Thank you


Solution

  • Try running java with -Djava.library.path:

    java -Djava.library.path=directory_where_your_library_is main_class