Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate JNI header file in Eclipse

I am using Eclipse to generate a JNI header file. I looked in program files\java\jre6\bin and found a lot of .exe and .dll files, but I couldn't find the command javah which was in the documentation for using JNI to create bindings to C libraries.
Any help?

like image 645
holy Avatar asked Mar 30 '12 09:03

holy


People also ask

What is Javah?

Description. The javah command generates C header and source files that are needed to implement native methods. The generated header and source files are used by C programs to reference an object's instance variables from native source code.

Does JNI make Java code machine dependent?

The JNI allows Java code that runs within a Java Virtual Machine (VM) to operate with applications and libraries written in other languages, such as C, C++, and assembly. In addition, the Invocation API allows you to embed the Java Virtual Machine into your native applications.


1 Answers

Use the following panel to define a new external tool for javah.exe.

Point "Location" to the javah.exe tool.

Set "Working Directory" to

${workspace_loc:/${project_name}/bin}

Set "Arguments" to:

-classpath ${project_classpath} -v -d ${workspace_loc:/${project_name}/src} ${java_type_name}

enter image description here

To run the tool, highlight the java source file in package explorer and run the tool.

enter image description here

Press F5 to refresh th project to see the newly generated file.

like image 127
Java42 Avatar answered Sep 27 '22 17:09

Java42