I have written a class called A(for ex)containing a native method inside a package called B(for ex). I have compiled it by ---c:B>javac A.java.Then I generated a header file just by running---c:B>javah -jni A.Is this the way for creating header file.Why because when I tried to run the code I got UnsatisfiedLinkError.

Alexander Krapf

There are a whole bunch of things that could go wrong. Most often, people run afoul of name-mangling when they build native implementations. Always remember the extern "C" for your methods.

The next most common problem is that people forget to specify the library path on which the JVM will try to locate native libraries. Use the -Djava.library.path= option for that purpose.

The next most common problem is that people forget to actually load the library in Java.

Other than that, there is a whole bunch of other possible issues related to ClassLoaders, special characters in package or classnames, etc., but those are impossible to diagnose without seeing all of your code.
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.