Native library: class file contains wrong class

Last Updated:

  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, compiled it (see in 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:

  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.

Share This Page