instagram

Java – Run javah from Eclipse

javah is use to create C header file for JNI. This tutorial explain how to run javah from Eclipse.

Create project structure as shown in below image.

Run javah from Eclipse

Create project omtJavah and create package com.omt.javah as shown in above image.

Now create new java class JavaH.java in com.omt.javah package.

JavaH.java
Copy Below code in JavaH.java

package com.omt.javah;

public class JavaH {
	public native void omtJavaH();
}

JavaH.java contains only one native methods ( public native void omtJavaH(); ).
Now we need to create Header (.h) file for JavaH.java class. For that we need to run javah -jni. We do this things using eclipse.

Select JavaH.java file and Goto “Run > External Tools > External Tools Configurations..” as shown in below image.

select external tools configurations

Click on External Tools Configurations.. it will open windows that shown in below image.

1. Select Program
2. Click on new button to add new Configurations..

External Tools Window

Now Fill below information in new configuration window.

1. Enter your configuration name. Here we entered Run_javah.

2. Select Location of javah.exe for that click on “Browse File System” button and select javah.exe file.

3. Select Working Directory path. This is your bin folder path of current project for that you need to click on “Browse Workspace” button and select bin folder of your current project. (Here we select omtJavah/bin )

4. Now Enter Below Arguments :


-jni -verbose -d "${project_loc}${system_property:file.separator}jni" ${java_type_name}


Copy Above line in Arguments

Enter properties

Now click on run button to create Header (.h) file of JavaH.java.

Refresh your project you will see following files and folder.

refresh your project

Share