Search code examples
javaheaderjava-native-interface

Generating Java JNI Header


All I'm trying to do is generate a JNI Header file using JDK Javah.exe program, but no matter what I try I keep getting the error message "Error: could not find class file for 'ddg.ndkTest.NativeLib'" (where ddg.ndkTest is the namespace and NativeLib is the java class file). Also, please note that to simplify the process further, I've copied my entire Android project to the Java directory.

I've tried the following commands, none of which have worked:

  • javah -jni ddg.ndkTest.NativeLib
  • javah -verbose -jni -classpath \NDKTest\bin\classes ddg.ndkTest.NativeLib
  • C:\Program Files\Java\jdk1.7.0_02\bin>javah.exe -jni -classpath \NDKTest\bin\classes\ ddg.ndkTest.NativeLib

If my package is called; "ddg.ndkTest", and my class is; "NativeLib.java", and my classpath above is correct. What should I write in my command window?


Solution

  • Try this:

    1. Build your classes first
    2. Change directory down to \NDKTest\bin\classes\
    3. Run javah ddg.ndkTest.NativeLib