I am trying to run cpp code in java. but getting this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no math in java.library.path
I have tried to link my library to the java.library.path using this command after
$ javac HelloJNI.java
$ java -Djava.library.path="/home/sneha/Videos/node-ffi-example/math.so" HelloJNI
But still the same error.
Here is my HelloJNI.java file
public class HelloJNI { // Save as HelloJNI.java
static{
System.loadLibrary("math"); // Load native library hello.dll (Windows) or libhello.so (Unixes)
// at runtime
// This library contains a native method called sayHello()
System.out.println(".so included");
}
// Declare an instance native method sayHello() which receives no parameter and returns void
private native int num();
// Test Driver
public static void main(String[] args) {
HelloJNI hj = new HelloJNI();
int num = hj.num(); // Create an instance and invoke the native method
System.out.println("Number: "+num);
}
}
Please help, Thanks !