Reputation: 23
code:
public class JniTest {
static {
System.load("/usr/lib/libJniTest.so"); //It run have no exception and true
//System.loadLibrary("libJniTest");
}
public native void sayHello();
public static void main(String[] args) {
System.out.println(System.getProperties().getProperty("java.library.path"));
new JniTest().sayHello();
}
}
If use the comments code instead of "System.load("/usr/lib/libJniTest.so")
, it will throw exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libJniTest in java.library.path!
I have input
export LD_LIBRARY_PATH=/usr/lib in /etc/profile and set vm arguments:
-Djava.library.path=/usr/lib
Help me, Please!
Upvotes: 1
Views: 149
Reputation: 3424
Set VM arguments with :
-Djava.library.path="${workspace_loc}/project_name:${env_var:PATH}"
and make sure that .so should be in your project folder
Upvotes: 1