1 |
Example
-
create java class - file ex1.java:
-
public class ex1 {
-
public native int funct();
-
static{ System.loadLibrary("ex1.so"); }}
-
create java byte code ex1.class: javac ex1.java
-
create ex1.h header file for native code: javah ex1
-
create ex1.c stub - interface between ex1 Java class and C language: javah -stubs ex1
-
implement native method libex1.c:
-
#include ex1.h; funct() { ... }
-
compile ex1.c and libex1.c and link it into dynamic library ex1.so
|