Java Native Interface (JNI) is a bridge between Java and C/s + +. In some cases, to improve the performance of Java programs and extend the functionality of Java programs, we need to use JNI. For example, when we download a JDBC jar package, we can see the dynamic link library containing the different platforms in the database:
This article describes how to create one of the simplest JNI dynamic link libraries for the ANDROID,MAC and Windows platforms.
Reference article:
Getting Started with JNI on Android, Windows and MacAndroid
Download the NDK and configure the path in eclipse:
Create an Android engineering Hellojni. Right-click the project, select Add Native support to automatically generate C + + projects:
Modify the C + + code to configure ANDROID.MK:
Clicking Save will automatically generate the dynamic link library libhellojni.so. You can also manually generate by command ndk-build :
Windows
Open Visual Studio and create a Win32 project Hellojni:
Select the DLL in the app type:
To configure the path of the header files and libraries:
Click Build to generate Hellojni.dll:
Mac OS X
Open Xcode and create a project hellojni :
Framework Selection STL:
In the build settings, configure the JAVAVM header file path and the library path:
Click Build to generate libhellojni.dylib:
How to use JNI in Java Engineering:
Declaration Native Interface:
Public native String Stringfromjni ();p ublic native static void Nativeprint ();
To load a dynamic-link library:
static {system.loadlibrary ("Hellojni");}
Source
https://github.com/dynamsoftrd/jni-
git clone https://github.com/DynamsoftRD/JNI-.git
How to create a Java JNI dynamic-link library for ANDROID,MAC and Windows platforms