• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Native library: class file contains wrong class

QuickNick

Newbie
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:
bad class file: .\NativeSample.class
class file contains wrong class: com.dsp.NativeSample
Don't we need C/C++ compiler to generate header file form Java class file?
 

Attachments

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.
 
Back
Top Bottom