Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javah error when trying to generate simple JNI .h file

843829Jun 30 2009 — edited Jun 30 2009
I'm trying to get the basic HelloWorld example to run, i;ve compile the following code in netbeans and found the generated .class file
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package HelloWorld;

/**
 *
 * @author jlovett
 */
class HelloWorld
{
        private native void print();
        
        public static void main(String[] args)
        {
            new HelloWorld().print();
        }

        static
        {
            System.loadLibrary("HelloWorld");
        }
}
the generated .class located at "C:\Documents and Settings\jlovett\My Documents\NetBeansProjects\HelloWorld\build
\classes\helloworld\HelloWorld.class"

i then navigated to that directory in the command prompt and typed "javah -jni -o HelloWorld.h HelloWorld" to try and generate the .h file but i a series of errors.
C:\Documents and Settings\jlovett\My Documents\NetBeansProjects\HelloWorld\build
\classes\helloworld>javah -jni -o HelloWorld.h HelloWorld

error: cannot access HelloWorld
bad class file: .\HelloWorld.class
class file contains wrong class: helloworld.HelloWorld
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
com.sun.tools.javac.util.Abort
        at com.sun.tools.javac.comp.Check.completionError(Check.java:164)
        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:159
)
        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
any help as to what i'm doing from or missing etc i much appreciated.

Regards, Jason
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2009
Added on Jun 30 2009
1 comment
261 views