I'm trying to create a JNI project in Eclipse using CDT. I'm following this tutorial.
So first I created my project as a Java project and created a HelloJNI
class in the default package, which contains some really basic code.
I then added a C nature to my project, selecting 'Makefile Project' in 'Project type' and 'Linux GCC' in 'Toolchains'.
Then I created a new directory called 'jni' to store all the C code. I then created a new file in eclipse called 'makefile' (note the lowercase name) and added this to it.
# Define a variable for classpath
CLASS_PATH = ../bin
# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)
# $* matches the target filename without the extension
HelloJNI.h : HelloJNI.class
javac -h -classpath $(CLASS_PATH) $*
I then created a build target called 'HelloJNI.h' in the jni folder, which automatically used the makefile. I then attempted to build the target, but I got this error:
javac -h -classpath ../bin HelloJNI
javac: invalid flag: ../bin
Usage: javac <options> <source files>
use -help for a list of possible options
make: *** [makefile:9: HelloJNI.h] Error 2
I am puzzled by the error message. Does javac recognize ../bin
as a flag? Is there some weird bug happening in Eclipse? If I try to do this in the terminal, I get the same error. I tried searching for answers, but found none.
This is my directory strcture:
-bin
HelloJNI.class
-jni
makefile
-src
HelloJNI.java
Edit: Changing the javac call to
javac -h -classpath $CLASS_PATH $*
gave me the following error:
error: Class names, 'LASS_PATH,HelloJNI', are only accepted if annotation processing is explicitly requested