Java Native Interface (JNI)
Java Native Interface (JNI) is one of the intersting interface by java By using Java Native I
This Article is for Simple Java not for Android:
Calling DLLs from Java
Calling C/C++ DLLs from Java
Introduction
In this walkthrough, we will show how C/C++ code compiled into a Windows DLL can be called from Java using J/Invoke.
We will be using Microsoft Visual Studio 2005 to create a DLL with C++ functions, and writing Java code with the help of the Eclipse Java IDE. The steps for other IDEs will be similar. We encourage you to 'walk-through' this exercise with us, even if you are not very familiar with Visual Studio or Eclipse - it is easy, and it is fun!
To run this example, you should be running Windows 2000, XP, Vista or 2003.
J/Invoke requires a Java SE developer kit. As it uses Java annotations, JDK version 5.0 or higher is needed. Get Java here.
Continue Reading ...
First a disclaimer - I'm a bit sketchy on this, it's been a while since I've used JNI.
Many JNI examples assume you own the code for the library you want to call, which in my experience is rarely the case. In the example you sight the javah util has been used to generate a header file, against which cpp implementation has been written - this is why you can see the jni header file and various Java keywords in the cpp file.
In order to use a 3rd party dll, you first need the documentation for that dll, without that you're dead in the water. The reason you need the documentation is that you're going to provide a wrapper dll that simply delegates to the 3rd party dll - you need to know how to call it and how to perform any type mappings. Obviously it's this wrapper that will contain all the JNI stuff to allow Java to make the call to that wrapper, which in turn calls the 3rd party dll.
There's various ways to do this but the easiest way I know is to use SWIG, which will generate all the C++ code required for the wrapper dll. It also helps to have someone that knows C++ on hand - they'll be invaluable writing interface files (.i or .swg files) that SWIG uses to generate the wrapper code.
I'm not a expert on these but i think you should use System.loadLibrary("comparejni");
http://blog.jayway.com/2010/01/25/boosting-android-performance-using-jni/
Hope it helped
I don't think you're going to be able to use a Windows native library (.dll) in an Android application. To load on Android, the code would need to be built into a .so.