Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnsatisfiedLinkError when using JNI?

I want to call a C program from Java program using JNI in linux ubuntu.

I am new to this and I have tried the sample program given in http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html . I have already created the .java, .h , .c and .so files. But when i tried to run the program I am getting the following error.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no Sample1 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at Sample1.main(Sample1.java:13)
like image 239
Poonam Hoshi Avatar asked Mar 28 '12 10:03

Poonam Hoshi


1 Answers

This exception is indicating that the .so is not available to the JVM.

Adding the directory where the .so exists to the LD_LIBRARY_PATH will resolve this. If the .so depends on other .so libraries the directories where these .so exist will also need added to LD_LIBRARY_PATH.

like image 71
hmjd Avatar answered Sep 22 '22 14:09

hmjd