Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Error when calling native method.

  1. #1

    Default Error when calling native method.

    Error when calling native method.

    I have an eclipse project with two classes. The class "SomeClass1" has a native method:

        public class SomeClass1 {
            // Load the native library.
            static {
            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:

    Anroid 1.6/
    Android Dependancies/

    - I cannot specify any command-line parameters to run the program.
    - I am running on a 64 bit platform with a 32 bit JRE.
    Last edited by kaufenpreis; October 18th, 2015 at 03:12 PM.

Similar Threads

  1. Replies: 1
    Last Post: June 26th, 2014, 08:08 AM
  2. LWJGL native compiled for ARM OpenGL ES Linux platform gives error
    By acrilex in forum Java Native Interface
    Replies: 1
    Last Post: June 5th, 2014, 11:01 AM
  3. [SOLVED] null pointer exception error for a method calling a graphics obj help please
    By jorys22 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: December 2nd, 2013, 03:02 PM
  4. Spring 3.2 -- 404 error calling a controller method from a link in a JSP
    By FHSerkland in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2013, 08:10 PM
  5. calling native c code from java using JNI
    By ashok_jeev in forum Java Native Interface
    Replies: 3
    Last Post: November 20th, 2012, 04:28 AM