|JNIEnv||Pointer to the JNI environment|
|jobject||The object which invoked the non-|
|jclass||The class which invoked the |
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 (
.h) files from the Java classes containing
javah. These files "instruct" the native code which methods it is responsible for implementing.
#include) in the C++ source files (
.cpp) implementing the
.dll). This library contains the native code implementation.
-Djava.library.path) and load it in the Java source file (
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