-
Book Overview & Buying
-
Table Of Contents
Mastering Eclipse Plug-in Development
By :
The Java Native Interface (JNI) is a standard way in which any Java program can interact with native code. The process for working with native code can be summarized as follows:
Write a Java class with a native method.
Compile the Java class as normal.
Run javah with the class name, which generates a header stub.
Write the native C function and export it with the given function signature.
Compile the code into a dynamically linked library.
Load the library into the runtime with System.loadLibrary.
Execute the native method as normal.
The name of the library is dependent on the operating system; some call the library name.dll, some call it libname.so, and others libname.dylib. However, Java just uses the real portion of the library name; so, all three platforms use the same Java code, System.loadLibrary("name"), to load the library.
For the purpose of this chapter, a native library will be created to perform a simple Maths operation class that...
Change the font size
Change margin width
Change background colour