Running javah tool from Eclipse

by Jay Jonas

The javah produces C header files and C source files from a Java class that are needed to implement native methods. The javah -jni is used to generate a C header file containing the function prototype for the native method implementation.

The javah can be configured as an external tool like this: click Run |External Tools |External Tools Configurations. This will invoke External Tools Configurations wizard.

Select Program Type and create a new launch configuration.

For Location, click on Browse File System and browse to the path of javah tool (typically <java_home>\bin).

For Working Directory, click on Browse Workspace and select upto project output directory (directory where class files reside – typically ${workspace_loc:/your.jni.project/bin})

Various options of javah command may be added here which is then followed by ${java_type_name} workspace variable which returns the fully qualified Java type name of the primary type in the selected resource.

The argument list instructs the tool to keep the generated header file in a directory named jni under the project folder. If -d option is not specified, the header files will be stored in bin folder itself.

"${project_loc}${system_property:file.separator}jni" ${java_type_name}
External Tools Configuration

External Tools Configuration

// That’s all, folks!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: