0
votes

I'm experimenting the use of JNI with Eclipse, using this tutorial and I fail to use the makefile as explained in the part "2.6 JNI in Eclipse - step 3".

When I right click on the jni folder, selecting "Build targets" => "Build" => and selecting the target HelloJNI.h => Build, I get the following error message :

10:19:12 **** Build of configuration Default for project HelloJNI **** make HelloJNI.h javac -h -classpath ../bin HelloJNI makefile:10: recipe for target 'HelloJNI.h' failed process_begin: CreateProcess(NULL, javac -h -classpath ../bin HelloJNI, ...) failed. make (e=2): Le fichier spécifié est introuvable.

make: *** [HelloJNI.h] Error 2

10:19:13 Build Finished (took 801ms)

and the last line of the makefile file shown below indicates there is an error (but which one ?)

# Define a variable for classpath
CLASS_PATH = ../bin

# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)

HelloJNI.h : HelloJNI.class
    javac -h -classpath $(CLASS_PATH) $*

I checked that I'm having a "make" file in "C:\MinGW\bin". I haden't so I made a copy of "mingw32-make.exe" and renamed it "make.exe".
I also tried to change the last intruction javac -h (...) to javah (...) but I get the same error.

I suppose the error line

CreateProcess(NULL, javac -h -classpath ../bin HelloJNI, ...) failed. make (e=2): Le fichier spécifié est introuvable. [The specified file is not found.]

should help me to understand what is wrong but I didn't succeed.

Thank you for your help

1

1 Answers

2
votes

The error does not come from javac ´- it is caused by javac not being in the PATH and the CreateProcess system call is unable to locate it, and hence the command is not executed. Nothing you change after javac is going to help there. Possible fixes are e.g.

  • adding the path of javac to PATH...
  • calling javac with the full path to it:

    c:/Foo/Bar/JavaSDK/bin/whatever/javac -h -classpath $(CLASS_PATH) $*