Issue
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)
Solution
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 thejni
directory, relative to the working directory. (which I set to the project itself, notbin
)-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 wantTEMP
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. .
Answered By - Botje
Answer Checked By - Senaida (JavaFixing Volunteer)