Generating header file

Hi Comrades! I have a problem generating a C/C++ header file from a class file

Look at this simple program:

package com.mypkg;

class DisplayResult

{

public static native int getValues();

public static native String getName();

public static void main(String[] args)

{

new DisplayResult().getValues();

new DisplayResult().getName();

}

static

{

System.loadLibrary("DisplayResult");

}

}

This compiles successfully to a class file. But when I try to generate a header file using this command:

javah -jni DisplayResult

this is what I get:

C:\Trials\trialJava\com\mypkg>javah -jni DisplayResult

error: cannot access DisplayResult

bad class file: .\DisplayResult.class

class file contains wrong class: com.mypkg.DisplayResult

Please remove or make sure it appears in the correct subdirectory of the classpath.

com.sun.tools.javac.util.Abort

at com.sun.tools.javac.comp.Check.completionError(Check.java:169)

at com.sun.tools.javadoc.DocEnv.loadClass(DocEnv.java:149)

at com.sun.tools.javadoc.RootDocImpl.<init>(RootDocImpl.java:77)

at com.sun.tools.javadoc.JavadocTool.getRootDocImpl(JavadocTool.java:156)

at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:330)

at com.sun.tools.javadoc.Start.begin(Start.java:128)

at com.sun.tools.javadoc.Main.execute(Main.java:66)

at com.sun.tools.javah.Main.main(Main.java:147)

javadoc: error - fatal error

2 errors

Please can anyone help me get out of this mess!

[1631 byte] By [OiyeMagohaa] at [2007-10-3 7:26:33]
# 1

The com.mypkg package name of your DisplayResult class must be within the complete class name.

So it should be:javah -jni com.mypkg.DisplayResult

Of course your .class file should be located under the com/mypkg folder

and you should be executing the command at the com/mypkg parent folder.

Next time please paste your code between [code] [/code] tags with the help of the code button just above the message box.

It makes the code readable.

Regards

jfbrierea at 2007-7-15 2:25:23 > top of Java-index,Java HotSpot Virtual Machine,Specifications...