Native library: class file contains wrong class


  1. QuickNick

    QuickNick Active Member

    Good day, dear friends.

    Yesterday I was given a task to introduce native functions in our application. I've never used C/C++ before, but it doesn't matter.
    The question is, to generate C header file from Java class.

    First of all, I wrote NativeSample.java, compiled it (see in native-sample.zip) and brought compiled file (.class) to $JDK/bin directory.

    Then I had tried "javah -jni NativeSample" - but I got this message:
    Don't we need C/C++ compiler to generate header file form Java class file?

    Attached Files:


    Advertisement
    :
  2. QuickNick

    QuickNick Active Member

    Sorry for premature alarm.

    The solution is, to create in $JDK directory the directory tree that repeats package tree of your class.

    For example, if my class is com.dsp.NativeSample, I'm creating directory "com" in $JDK directory, then directory "dsp" in directory "com", then move my compiled class to directory "dsp".

    Then command "javah -jni com.dsp.NativeSample"

    I saw more simple solution with classpath, so you may search by this word.
Loading...

Share This Page