The first step in development is to study the use of Java JNI, because the DLL library needs to be called in Java because of the project to do some graphics processing. Suddenly found that the use of Android Jni like this (hemp egg, not the same, but the need to use the so dynamic link library in Android).
The first step is to create a Java project, name Jnidemo, add Jnidemo.java the second step to add the native method in the Java class
/**@author*/Publicclass jnidemo{ Public nativestaticvoid set (int i); Public native Static int get ();}
Step three using the Javah command to generate the header file
Execute Javah javah com.bk.jnidemo.JniDemo in cmd, generate com_bk_jnidemo_jnidemo.h header file
The fourth step is to create the DLL project using Vs2010
Create Win32 project, project name Jnidemo
Fifth Step copy Com_bk_jnidemo_jnidemo.h,jni.h,jni_md.h to vs Engineering cpp file directory
Where jni.h is in the JDK's include directory, jni_md.h in the JDK Include\win32 directory
Add the header file directory to the project com_bk_jnidemo_jnidemo.h, #include <jni.h> change to #include "jni.h"
Sixth step implementation of C + + method in Jni.cpp
Seventh Step build 64-bit DLL library
Modify Configuration Manager First
Then build the 64dll Library
The eighth step is to copy the 64-bit DLL library to the Java Jnidemo Project root directory and modify the Jnidemo.java
Note the 64-bit DLLs in the X64 directory, and then modify the Jnidemo.java as follows
1 PackageCom.bk.jnidemo;2 3 Public classJnidemo {4 Static{5System.loadlibrary ("Jnidemo");6 } 7 Public native Static voidSetinti);8 Public native Static intget ();9 Ten Public Static voidMain (string[] args) { OneSet (100); A System.out.println (Get ()); - - } the}
Nineth step, get it done.
Java calls C + + (Java call dll) brother Hong teach You