Also notice that I statically load the library into the class. Well, before we get to the function, we need to do a few things. First off, we need to compile the java into bytecode and extract some C style headers. This will give you jniexample.class . Now that we have the bytecode class ready to go, we need to generate a JNI style header we can use with our C code.
Lets examine it for a second and see what happened.
The native method function definition in the code must match the generated function prototype in the header file. With the header in place, lets build this beast. Below is jniexample.c, the main C source code file used as the native function. See jniexample.java for compyright information. If supported for the target machines, generate position-independent code, suitable for use in a shared library.