Forum Stats

  • 3,826,337 Users
  • 2,260,628 Discussions
  • 7,896,905 Comments

Discussions

Javah error: could not find class file for 'com.ntv.ndkjni'

2717046
2717046 Member Posts: 2
edited Jul 24, 2014 2:07AM in Java Native Interface (JNI)

Hi,

My project directory  : C:\ndkJNI

My java file directory : C:\ndkJNI\src\com\ntv\ndkjni

My package name    : com.ntv.ndkjni


1 ) I entry command prompt at C:\ndkJNI\src\com\ntv\ndkjni

2 ) Javac test.java and create test.class succesfully. test.class is in  C:\ndkJNI\src\com\ntv\ndkjni folder.

3 ) Later I used Javah, try below javah variously

     a)  javah -classpath C:\ndkJNI\src\com\ntv\ndkjni test

     b)  javah -classpath C:\ndkJNI\src\com\ntv\ndkjni.test

     x) javah -classpath C:\ndkJNI\src\com\ntv\ndkjni com.ntv.ndkjni.test

     y) javah -classpath C:\ndkJNI\src\com\ntv\ndkjni com.ntv.ndkjni test

     c)  javah -classpath C:\ndkJNI\src\com\ntv\ndkjni com.ntv.ndkjni.test

     d)  javah  com.ntv.ndkjni.test

     e) javah  com.ntv.ndkjni test

     f) javah  com.ntv.ndkjni test.class-> (error: exception in a thread illegal argument exception)

    

I am searching  for 5 day. I couldnt find solution. I try different computer. I tried ubuntu and win8, the error still with me.

Thats interesting when I delete the package com.ntv.ndkjni; from java file,  then create class file again with javac then javah can create header file succesfully.


Please help me.


*****************************test.java**************************

package com.ntv.ndkjni;

public class test {

  static

  {

  System.loadLibrary("hello");

  }

    public static native int toplama(int sayi1,int sayi2);

  }

******************************************************************

aaa.PNG

Tagged:

Best Answer

  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    Answer ✓

    javah takes a fully qualified class name so in your case that would be

    com.ntv.ndkjni.test

    As with all things related to java the class path is used to resolve the class based on the fully qualified name.  The name resolves STARTING at the path and then attempts to find the class BELOW the classpath by resolving the name.

    Because of that your class path should be the following

    C:\ndkJNI\src



    2717046

Answers

  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    Answer ✓

    javah takes a fully qualified class name so in your case that would be

    com.ntv.ndkjni.test

    As with all things related to java the class path is used to resolve the class based on the fully qualified name.  The name resolves STARTING at the path and then attempts to find the class BELOW the classpath by resolving the name.

    Because of that your class path should be the following

    C:\ndkJNI\src



    2717046
  • 2717046
    2717046 Member Posts: 2
    edited Jul 24, 2014 2:07AM

    Thanks a lot...

    As your advices, I entry this   javah -jni -classpath C:\ndkJNI\src com.ntv.ndkJNI.test

    Javah works clearly now.


This discussion has been closed.