我将它输入到命令提示符中,但我不确定为什么它说它不是有效的类名,因为它在磁盘上具有位置和完全限定的类名。Java - 版本有效,我正在使用 JDK 运行最新版本的 JVM,CLASSPATH 也已正确配置。
课程是这样的:
package JNI;
public class Main {
public native void printTitle();
public static void main(String[] args) {
Main main = new Main();
main.print();
}
public void print(){
System.out.println("The print subroutine has finished.");
}
命令行参数是:
C:\Users\USER\Documents\NetBeansProjects\JNI Test Project\build\classes\JNI>javah -jni -classpath "C:\Users\USER\Documents\NetBeansProjects\JNI Test Project\build\classes\JNI" JNI.Main.class
Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: JNI.Main.class
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:177)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:509)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:335)
at com.sun.tools.javah.Main.main(Main.java:46)