Javah error while using it in JNI

前端 未结 14 1672
离开以前
离开以前 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:59

    I encountered the same error and using http://www.inonit.com/cygwin/jni/helloWorld/header.html link I was able to successfully generate the .h file. I used the following command

    C:\Program Files\Java\jdk1.6.0_21\bin>javah -d C:\Prachi\Android\Workspace_QP_re
    structure\HelloWorld\bin\example\jni -classpath C:\Prachi\Android\Workspace_QP_r
    estructure\HelloWorld\bin example.jni.HelloWorld
    

    here example.jni is my package name and C:\Prachi\Android\Workspace_QP_re structure\ is where my eclipse workspace path.

    Hope this helps you

    0 讨论(0)
  • 2020-12-01 05:59

    I had similar issues and used the -verbose option. I had to add a ; to the front of the classpath option.

    C:\Projects\HelloWorld\src>javah -verbose -classpath c:\projects\HellowWorld\build\classes helloworld.HelloWorld
    error: cannot access helloworld.HelloWorld
    class file for helloworld.HelloWorld not found
    javadoc: error - Class helloworld.HelloWorld not found.
    [ Search Path: c:\jdk\jre\lib\resources.jar;c:\jdk\jre\lib\rt.jar;c:\jdk\jre\lib    \sunrsasign.jar;c:\jdk\jre\lib\jsse.jar;c:\jdk\jre\lib\jce.jar;c:\jdk\jre\lib\ch    arsets.jar;c:\jdk\jre\classes\c:\projects\HellowWorld\build\classes ]
    Error: No classes were specified on the command line.  Try -help.
    
    C:\Projects\HelloWorld\src>javah -verbose -classpath ;c:\projects\HellowWorld\build\classes helloworld.HelloWorld
    [ Search Path: c:\jdk\jre\lib\resources.jar;c:\jdk\jre\lib\rt.jar;c:\jdk\jre\lib\sunrsasign.jar;c:\jdk\jre\lib\jsse.jar;c:\jdk\jre\lib\jce.jar;c:\jdk\jre\lib\charsets.jar;c:\jdk\jre\classes\;c:\projects\HellowWorld\build\classes ]
    [Creating file helloworld_HelloWorld.h]
    [search path for source files: .,c:\projects\HellowWorld\build\classes]
    [search path for class files: c:\jdk\jre\lib\resources.jar,c:\jdk\jre\lib\rt.jar,c:\jdk\jre\lib\sunrsasign.jar,c:\jdk\jre\lib\jsse.jar,c:\jdk\jre\lib\jce.jar,c:\jdk\jre\lib\charsets.jar,c:\jdk\jre\classes,c:\jdk\jre\lib\ext\dnsns.jar,c:\jdk\jre\lib\ext\localedata.jar,c:\jdk\jre\lib\ext\sunjce_provider.jar,c:\jdk\jre\lib\ext\sunmscapi.jar,c:\jdk\jre\lib\ext\sunpkcs11.jar,.,c:\projects\HellowWorld\build\classes]
    [loading .\helloworld\HelloWorld.class]
    [loading java\lang\Object.class(java\lang:Object.class)]
    [loading java\lang\Throwable.class(java\lang:Throwable.class)]
    [loading java\lang\Class.class(java\lang:Class.class)]
    [done in 409 ms]
    

    Without the ;, this is the end of the search path: c:\jdk\jre\classes\c:\projects\HellowWorld\build\classes

    I was able to get this far because of the examples above.

    0 讨论(0)
提交回复
热议问题