Reputation: 507
I am trying to follow a tutorial (http://www.lithiumhead.com/notes/windows_jni) to generate the c++ header file from Eclipse. It is based on using javah (like many other tutorials I have found), but javah does not exist in newer versions of jdk. Simply replacing javah by javac does not work as I get "error: invalid flag: -jni". I know I have to use -h flag, but I do not know where! Here is a snapshot of the current state:
I would appreciate your help, as well as a link to a good (step-by-step) tutorial that is up-to-date (works with newer versions of jdk, eclipse, etc)
Upvotes: 0
Views: 4530
Reputation: 1
try this:
-h jni -d ${env_var:TMPDIR} -s ${selected_resource_loc}
Upvotes: 0
Reputation: 30937
You almost got it, you simply need to change the flags a bit. The full line is
-h jni -d ${env_var:TMPDIR} ${selected_resource_loc}
broken into parts:
-h jni
: output headers in the jni
directory, relative to the working directory. (which I set to the project itself, not bin
)-d ${env_var:TMPDIR}
: Output class files into a temporary directory. We do not care about it, so I made it output to $TMPDIR
. On Windows you probably want TEMP
instead.${selected_resource_loc}
: Pass the full path to the currently selected file. You can also hardcode "HelloWorld.java" instead.Running the tool generated a jni/helloJNI_HelloJNI.h
for me.
Here's a screenshot of my window, for reference. .
Upvotes: 2