JNI in a Nutshell

1.Create Java Source code with native methods
native returnType method(arguments)

2.Compile Java source code and obtain the class files

3.Generate C/C++ headers for the native methods; javah gets the info it needs from the class files.

4.Write the C/C++ source code for the native method using the function prototype from the generated include file and the typedefs from include/jni.h

5.Compile the C/C++ with the right header files.

6.Use the linker to create a dynamic library file.

7.Execute a Java program that loads the dynamic library
static{ System.loadLibrary("dynamic library") }

comments powered by Disqus