Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

System.load() and java.lang.UnsatisfiedLinkError

ahhughesJul 20 2009 — edited Jul 24 2009
Hi All,

I'm forced to dynamically load dll libraries into the jvm (can't use -Djava.library.path) and consequently I must use [System.load()|http://java.sun.com/javase/6/docs/api/java/lang/System.html#load(java.lang.String)] .

With reference to the attached code....
* A java.lang.UnsatisfiedLinkError is thrown by SomeJNIWrapperClass theInstance = new SomeJNIWrapperClass();.
* The System.load("C:/path/to/the/nativelib.dll"); does NOT throw any exception, indicating success! (javadoc: [System.load()|http://java.sun.com/javase/6/docs/api/java/lang/System.html#load(java.lang.String))
* I have the correct and absolute path to the nativelib.dll (this is not the problem).
* Everything works perfectly if I test this with the use of -Djava.library.path command line argument.

What I am doing wrong here? If anyone can help me out, THANK YOU :)
public class TheTest {

    public static void main(String[] args){
        try{
            System.load("C:/path/to/the/nativelib.dll");
            SomeJNIWrapperClass theInstance = new SomeJNIWrapperClass();
        } catch (Exception e){
            e.printStackTrace();
        }

    }
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2009
Added on Jul 20 2009
19 comments
4,899 views