I am writing a simple demo JNI project in Eclipse to integrate Java and C code. I have installed the CDT plugin for Eclipse to do this. With this project structure I have my HelloJNI java file inside the '(default package)' of Eclipse and have no problems using the makefile to generate a HelloJNI.h C header file.
My Makefile:
# 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
javah -classpath $(CLASS_PATH) HelloJNI
The problem is that I cannot figure out how to get this to work with HelloJNI.java being inside a package such as com.example instead of the default package. i.e. this structure. When running the same make target I get the error output:
make: *** No rule to make target 'HelloJNI.class', needed by 'HelloJNI.h'. Stop.
I attempted to add the package name to the javah command:
javah -classpath $(CLASS_PATH) com.example.HelloJNI
...but get the same error.
I attempted to change the classpath to:
CLASS_PATH = ../bin/com/example
...but get the following error:
make HelloJNI.h
javah -classpath ../bin/com/example HelloJNI
Error: Could not find class file for 'HelloJNI'.
What do I need to do with my makefile to make this work?