Sunday, 15 September 2013

Create JNI File from Java Class file

Create a Simple Java Project as given below

package com.example.helloworld;

public class HelloWorldActivity {

    static {
        System.loadLibrary("hello-jni");
    }
   
    public native String stringFromJNI();

}

Compile it. Say the directory is "D:\Project\J2SE Workspace\HelloWorld\bin\classes", then go to this directory where the package starts for the class file, then give

javah com.example.helloworld.HelloWorldActivity

It will create a JNI class for you with the required functions provided in the Java file.

No comments:

Post a Comment