Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsatisfied Link Error when using System.loadLibrary()?

Tags:

java

For some reason, I'm getting a pesky Unsatisfied Link Error in my java app.

This is the offender in question:

System.loadLibrary("psjw");

Despite the library psjw.dll clearly being in the same source package as this class.

Please help.

like image 610
Aaron Hammond Avatar asked Jun 18 '10 17:06

Aaron Hammond


People also ask

What does system loadLibrary do?

The System. loadLibrary() takes as parameter a library name, locates a native library that corresponds to that name, and loads the native library. For information about how a native library is located by the System.


2 Answers

Make sure the psjw.dll is either on your PATH or java.library.path.

Ex: psjw.dll may be in /usr/lib then your command would be java -Djava.library.path=/usr/lib ur.package.UrClass

Test your setup using a stripped down class:

public class TestLoadLibrary {

    public static void main(String[] args) {

        String libPath = System.getProperty("java.library.path");
        System.out.println("java.library.path=" + libPath);

        String libraryName = "psjw";
        System.out.println("Trying to load '" + libraryName + "'");
        System.loadLibrary(libraryName);
    }
}
like image 159
DeezCashews Avatar answered Oct 09 '22 21:10

DeezCashews


Try to set explicity the library path when starting the JVM: -Djava.library.path="Directory of DLL"

like image 25
Petar Minchev Avatar answered Oct 09 '22 21:10

Petar Minchev