Monday, 14 March 2011

JNI header file generation using Eclipse


Here is an example of using the External Tools Configuration in Eclipse to generate the JNI header file under WindowXP.

1) Choose External Tools Configuration in the tool bar:


2) Under the Main tab of a new configuration, setup the following parameters:
Location: [location of javah.exe (e.g. C:\Program Files\Java\jdk1.6.0_14\bin\javah.exe)]
Working Directory: [project directory (e.g. ${workspace_loc:/camera})]
Arguments:
-jni
-classpath .;[directory of the .class file (e.g. ${workspace_loc:/camera}/bin)]
-o [output file name (e.g. ${workspace_loc:/camera}/pointgrey_trigger/pointgrey_trigger/firefly_driver_jni.h)] [java file with the native methods declaration (e.g. edu.mit.yingyin.camera.WebcamDriverFirefly)]

Note that in *nix OS, the classpaths are concatenated using ":".

1 comment :