Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - javah doesn't find my class

I am having troubles generating the C header file for JNI using javah.

Here's the script I use while standing in the <project-dir>\bin directory:

javah -classpath C:\PROGRA~2\Android\android-sdk\platforms\android-8\android.jar com.test.JniTest

As return I get:

ERROR: Could not find class file for 'com.test.JniTest'.

Even though the class JniTest certainly is in \com\test.

What am I doing wrong?

like image 785
KaiserJohaan Avatar asked Oct 03 '11 13:10

KaiserJohaan


2 Answers

You specify the classpath to contain only android.jar.

You also need to include the location where your classes are stored. In your case it is the current directory, so you need to use . (separated by ; on Windows). The invocation should look like this:

javah -classpath C:\PROGRA~2\Android\android-sdk\platforms\android-8\android.jar;. com.test.JniTest
like image 127
Joachim Sauer Avatar answered Nov 15 '22 20:11

Joachim Sauer


If you are on Linux or MAC-OS, use ":" to separate the directories for classpath rather than ";" character: Example:

javah -cp /Users/Android/android-sdk/platforms/android-xy/android.jar:. com.test.JniTest
like image 21
VJ Vélan Solutions Avatar answered Nov 15 '22 21:11

VJ Vélan Solutions