Jainathan Leung
Jainathan Leung

Reputation: 1157

System.loadLibrary() gives java.lang.UnsatisfiedLinkerError: Can't load library

I'm having an issue with loading a simple .dll through java's System.loadLibrary("name.dll"); I have one copy of the dll in C:\libraries\name.dll as well as another copy in the system32 folder. Note that C:\libraries is NOT in my path environment variable. For some reason, when I call System.loadLibrary("name.dll"), I am getting:

java.lang.UnsatisfiedLinkError: Can't load library: C:\libraries\name.dll
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1706)
    at java.lang.Runtime.load0(Runtime.java:770)
    at java.lang.System.load(System.java:1003)

Even after I removed name.dll from C:\libraries, I am still getting this same error. Is there any reason why System.load is finding the .dll in a place that is not in the path, and why is it still looking in that place even after the file has been removed?

Upvotes: 0

Views: 3364

Answers (1)

bmargulies
bmargulies

Reputation: 100023

You need to change -Djava.library.path to point to system32 instead of C:\libraries.

Upvotes: 2

Related Questions