JNI: Getting Started

Write something simple in a java class such as below:
package com.sample;

class HelloWorld {
public native void print();
public static void main(String[] args) {
new HelloWorld().print();
}
static {
System.loadLibrary("HelloWorld");
}
}


Compile the java class

javac HelloWorld

Use javah to spit out the JNI header file

javah -jni -classpath "(path.to.src)" com.sample.HelloWorld

No comments: