Error when calling native method.
I have an eclipse project with two classes. The class "SomeClass1" has a native method:
Code:
public class SomeClass1 { // Load the native library. static { System.loadLibrary("thelibraryname"); } public native void some_method(); // implemented in library: "thelibraryname" // .... other non methods ....
The other class "SomeClass2" uses the native method of "SomeClass1". However when it calls that method it throws a runtime exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no thelibraryname in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at x.x.x.SomeClass1.<clinit>(SomeClass1.java:128)
at SomeClass2.main(SomeClass2.java:10)
I think the error has something to do with java not knowing where to find the library. Probably I need to provide a reference to the native library somewhere. Note that eclipse does not indicate any errors at compile time, only at runtime.
Does anybody know what causes this error and how to solve it?
The directory struture of my eclipse project looks like this:
Code:
ProjectName
Anroid 1.6/
Android Dependancies/
src/
SomeClass1.java
SomeClass2.java
bin/
libs/
armeabi/
libthelibraryname.so
armeabi-v7a/
libthelibraryname.so
x86/
libthelibraryname.so
<some-other-dirs-and-files>
Thanks!
PS:
- I cannot specify any command-line parameters to run the program.
- I am running on a 64 bit platform with a 32 bit JRE.