Microsoft SDK for Java

Javah

The C Header and Stub File Generator Utility (javah) produces C header and source files from a Java class. These files allow Java and C code to interact.

Use one of the following commands to run javah.

javah [options] [classname]

Javah Command-Line Arguments

options One or more javah options.
classname Java class file to generate C code from.

Javah Command-Line Options

-classpath -d -jni -o -stubs -td -trace -version -v

Usage Notes

Javah generates C header and source files that are needed to implement native methods. The generated header and source files are used by C programs to reference an object's instance variables from native source code. The .h file contains a struct definition whose layout parallels the layout of the corresponding class. The fields in the struct correspond to instance variables in the class.

The name of the header file and the structure declared within it are derived from the name of the class. If the class passed to javah is inside a package, the package name is prepended to both the header file name and the structure name. Underscores (_) are used as name delimiters.

By default javah creates a header file for each class listed on the command line and puts the files in the current directory. Use the -stubs option to create source files. Use the -o option to concatenate the results for all listed classes into a single file.

The native method interface, Java Native Interface (JNI), does not require header information or stub files. Javah can still be used with the -jni option to generate the native method function prototypes needed for JNI-style native methods. The result is placed in the .h file.

Note   You must set the CLASSPATH environment variable to make sure this tool works. You can set your class path directly on the command line or use the javah -classpath option. Set your class path to C:\%Windir%\Java\Classes\Classes.zip. To make sure you have the latest classes installed, you should also run clspack –auto after setting the class path. If you see the message "java.lang.Object not found: aborting" when you run javah, type clspack –auto, let it run, and then try running javah again.

See Also

Javah Options

© 1999 Microsoft Corporation. All rights reserved. Terms of use.