Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsatisfiedLinkError

java.lang.UnsatisfiedLinkError

I'm using the hello-jni example, and for whatever reason, I'm getting a java.lang.UnsatisfiedLinkError when I try to call the hello-jni library. Any ideas why? Do I have to set my path somewhere?

in HelloJni.java:

public native String  stringFromJNI();

and

static {
    System.loadLibrary("hello-jni");
}

in hello-jni.c:

jstring
Java_com_bdunlay_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)->NewStringUTF(env, "Hello from JNI !");
}

exception trace

the .so file is... project_root/libs/armeabi/libhello-jni.so

like image 908
Brian D Avatar asked Jan 27 '11 06:01

Brian D


1 Answers

your native have no JNIEXPORT. It usually declares in header file with function declaration.

We will use javah -jni to generate the header

like image 79
qrtt1 Avatar answered Sep 29 '22 23:09

qrtt1