본문 바로가기

java

generate java JNI Header

Really simple question causing a really annoying problem. 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??

I'm really getting frustrated with this as this should be the easy part, so any help would be fantastic thanks.

   
does the directory \ndktest\bin\classes\ddg\ndkTest exist? that's what your second attempt is looking for. – bmargulies Jul 3 '12 at 14:27
   
Yes I am able to view the entire directory and see the actual NativeLib.class file where i was pointing to, making it even more frustrating. – Ice Phoenix Jul 4 '12 at 12:51

Try this:

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