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!

How to set java.library.path form code

843829Apr 15 2005 — edited Nov 8 2005
I'm new to JNI. I see there are several ways to set JVM to look for libraries dll, so, etc.
	System.setProperty("java.library.path", ".");
	System.loadLibrary("hello");
That's when UnsatisfiedLinkError
java.lang.UnsatisfiedLinkError: no hello in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
	at java.lang.Runtime.loadLibrary0(Runtime.java:822)
	at java.lang.System.loadLibrary(System.java:992)
	at HelloWorld.main(HelloWorld.java:17)
But if I comment the line that sets the java.library.path and call the program with the command java -Djava.library.path=. HelloWorld works.
The question is: Why is not working? How should it be the property setup? I rather don't set Variables, or use -D option.

Thanks in advance.

PD: If it helps I'm using JDK 1.5.0_01 on Linux kernel 2.6.8
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2005
Added on Apr 15 2005
16 comments
3,063 views