Javah tool error: Could not find class file for hellojni

后端 未结 6 1271
無奈伤痛
無奈伤痛 2020-12-13 13:46

I am trying to create a header file using javah tool from command line on windows 7 OS but i am failing all the time.

I have followed different ways and even read t

6条回答
  •  渐次进展
    2020-12-13 13:53

    If you are using eclipse: append -classpath PATH_OF_PACKAGE_TOP into javah CLASSNAME

    Example:javah -classpath . com.byf.test.JNI

    my tree : `
    .
    ├── com
    │   └── byf
    │       └── test
    │           └── JNI.java
    └── libcall.so`
    
    
    result:`
        byf@byf-Ubuntu:~/code/workspace_eclipse_java/JAVA_YF/src$ javah -classpath . com.byf.test.JNI
        byf@byf-Ubuntu:~/code/workspace_eclipse_java/JAVA_YF/src$ ls
        com  com_byf_test_JNI.h  libcall.so
        byf@byf-Ubuntu:~/code/workspace_eclipse_java/JAVA_YF/src$ cat com_byf_test_JNI.h 
        /* DO NOT EDIT THIS FILE - it is machine generated */
        #include 
        /* Header for class com_byf_test_JNI */
    
        #ifndef _Included_com_byf_test_JNI
        #define _Included_com_byf_test_JNI
        #ifdef __cplusplus
        extern "C" {
        #endif
        /*
         * Class:     com_byf_test_JNI
         * Method:    add
         * Signature: (II)I
         */
        JNIEXPORT jint JNICALL Java_com_byf_test_JNI_add
          (JNIEnv *, jclass, jint, jint);
    
        #ifdef __cplusplus
        }
        #endif
        #endif
        `
    

提交回复
热议问题