Search code examples
javacmdjava-native-interface

Generating Java header file error


Sorry for asking but I am having trouble generating a Java header file from my code - in command prompt I typed:

javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main

From what I've read that should have worked but I get this error:

Error: Could not find class file for 'jnidemojava.Main'.

Before you say I forgot to clean and build to compile it I did, but I still have this error if you need more info just ask .

Update: Problem was solved


Solution

  • It seems your command is right. In which platform you run your command? Be cautious to the file separator, it's \ in Windows and / in *NIX.

    So in Windows you should

    javah -o JNIDemoJava.h -classpath JNIDemoJava\build\classes jnidemojava.Main
    

    In *NIX, you should

    javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main