Javah error while using it in JNI

前端 未结 14 1714
离开以前
离开以前 2020-12-01 05:27

Command:

javah -jni JavaHowTo

Result:

error: cannot access JavaHowTo 
class file for JavaHowTo not found

javadoc: error -          


        
14条回答
  •  没有蜡笔的小新
    2020-12-01 05:38

    How to generate a `JNI Header` file from an `Android class` file using `javah` (`.java` or `.class` BOTH work equally well).
    For Eclipse project on Windows:
    Goto the directory where the src, bin and jni folders are (so we can use relative paths to src or bin and jni): cd C:\Android\workspace5\AndroidImageFilter I assume `javah` is in your `PATH` (It is in something like : `C:\Program Files\Java\jdk1.7.0_79\bin\javah.exe`): javah -classpath c:\Android\sdk\platforms\android-19\android.jar;./src/ -d ./jni cn.Ragnarok.NativeFilterFunc ^ ^ ^ ^ ^ ^ ^ ^ ^ | | | | | | | | | Your android:targetSdkVersion="16"----------------------------+ | | | | | | | | | | | | | | | | | | | | | | | path to android.jar ---------+---------------------------------------+ | | | | | | | | | | | | | | | | | | | | | | | | semicolon (;) important ! --------------------------------------------------+ | | | | | | | | | | You can use the source directory (yes you can !) (OR the /bin/classes/ dir)-----+ | | | | | | | | Where to put the output file (cn_Ragnarok_NativeFilterFunc.h in this case)-----------+---+ | | | | The dot (.) spearated full package name path to the .java source file WITH file name --------+ | | File name of a java class -------------------------------------------------------------------------------------+ For Android Studio on Windows e'g': ^ cd C:\Android\workspace5\AndroidImageFilter\app\src\main | and usr java INSTEAD of src ----------------------------------------------------+

    See http://kn-gloryo.github.io/Build_NDK_AndroidStudio_detail/ for a better way.

    If you have a lot of filenames (of java classes) you can use a file with a list of classes.
    If you are on Linux or MAC-OS, use ":" (colon) to separate the directories for classpath rather than ";"
    See reference http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javah.html

提交回复
热议问题