Reputation: 41
In my project, I have a wrapper class named PlayerCluster.java
, which loads the native lib, and provides native functions. If I changed the class name (PlayerCluster.java
) or its package, I get java.lang.UnsatisfiedLinkError
when native function is invoked.
Why do I get this error when I rename the class name? Is there an approach by which native lib must be loaded in a specific java class?
Upvotes: 2
Views: 608
Reputation: 13986
If you rename the class then you must also rename your JNIEXPORT
methods in your native library so they match the new Java class name and then rebuild your native lib.
For example, given this method signture:
JNIEXPORT jobjectArray JNICALL
Java_com_mn_rootscape_utils_NativeMethods_getFilesPermissions( JNIEnv* env, jobject thizz, jobjectArray filePathsArray )
NativeMethods
is the Java class which, as you can see, is part of the native function signature.
Upvotes: 2