When you run javah -jni command flatly refuses to find the required class:

$ PROJECT_DIRECTORY / bin $ javah -jni bt.nativeclient.BtnativeActivity

error: cannot access bt.nativeclient.BtnativeActivity class file for bt.nativeclient.BtnativeActivity not found javadoc: error - Class bt.nativeclient.BtnativeActivity not found. Error: No classes were specified on the command line. Try -help

My java class has the address: $ PROJECT_DIRECTORY / src / bt / nativeclient / BtnativeActivity.java and has the form:

 package bt.nativeclient; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class **BtnativeActivity** extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText( stringFromJNI() ); setContentView(tv); } public native String stringFromJNI(); static { System.loadLibrary("hello-jni"); } } 

I tried running javah from: $PROJECT_DIRECTORY / bin , $PROJECT_DIRECTORY / src , just from $PROJECT_DIRECTORY . I tried to specify the path to search for a class through the option -classpath :

 $PROJECT_DIRECTORY/src javah -classpath :. bt.nativeclient.BtnativeActivity 

Moreover, if you enable the -verbose option, the -verbose command says that it corrupted my class in the directory where this very class it was supposed to find:

$PROJECT_DIRECTORY **javah -verbose -classpath :./src -jni** **bt.nativeclient.BtnativeActivity** error: cannot access bt.nativeclient.BtnativeActivity class file for bt.nativeclient.BtnativeActivity not found javadoc: error - Class bt.nativeclient.BtnativeActivity not found. [ **Search Path**: /usr/lib/jvm/java-6-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/netx.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/plugin.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/modules/jdk.boot.jar:/usr/lib/jvm/java-6-openjdk/jre/classes/:**./src** ]

I tried all possible combinations, but did not find a solution. It seems to me that I missed some small detail due to my inexperience, can someone help me please?

  • Check the access rights to your source directory - Barmaley
  • @ Alexey Vykhristyuk; If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - angry

1 answer 1

Let it be pointed to the .class file, they are not in bin but in bin \ classes. Klasspas does not point to your source files, but to additional libraries, if they are not there, just call the command from the bin \ classes folder

 >javah <пакет>.<пакет>.<класс> 

Should work.

  • Thank you, you really helped. - SIGSEGV