Java Native Methods Interface In this project, a C version of the arithmetic functions are implemented and are used
both in client and server side.
static {
System.loadLibrary("Arithmetic");
}
// calls for native C functions
public native int Add(int a, int b);
.......
A Java method loadLibrary() is used to load the library Arithmetic which is going
to be implemented. This library must have the functions which are defined as
public native
% javac Arithmetic.java % javah -jni AritmeticThis header holds the function declarations: native/Arithmetic.h (In order to access this file the system must be built!:)
% cc -G Arithmetic.c -I/afs/bp.ncsu.edu/contrib/jdk117/java/include \
-I/afs/bp.ncsu.edu/contrib/jdk117/java/include/solaris -o libArithmetic.so
The pathnames are specific to the environment that we used. If you use a different
environment, change pathnames accordingly.
For more information about JNI, these links can be checked out: |