[{“Name”:“Java SE 1.1”,“GroupName”:null},{“Name”:“Java SE 1.2”,“GroupName”:null},{“Name”:“Java SE 1.3”,“GroupName”:null},{“Name”:“Java SE 1.4”,“GroupName”:null},{“Name”:“Java SE 5”,“GroupName”:null},{“Name”:“Java SE 6”,“GroupName”:null},{“Name”:“Java SE 7”,“GroupName”:null},{“Name”:“Java SE 8”,“GroupName”:null},{“Name”:“Java SE 9 (Early Access)”,“GroupName”:null}]
Parameter | Details |
——— | —–– |
JNIEnv | Pointer to the JNI environment |
jobject | The object which invoked the non-static native method |
jclass | The class which invoked the static native method |
Setting up JNI requires both a Java and a native compiler. Depending on the IDE and OS, there is some setting up required. A guide for Eclipse can be found here. A full tutorial can be found here.
These are the steps for setting up the Java-C++ linkage on windows:
.java) into classes (.class) using javac..h) files from the Java classes containing native methods using javah. These files “instruct” the native code which methods it is responsible for implementing.#include) in the C++ source files (.cpp) implementing the native methods..dll). This library contains the native code implementation.-Djava.library.path) and load it in the Java source file (System.loadLibrary(...)).Callbacks (Calling Java methods from native code) requires to specify a method descriptor. If the descriptor is incorrect, a runtime error occurs. Because of this, it is helpful to have the descriptors made for us, this can be done with javap -s.