You use the
javah tool to generate C header and source files from a Java class.
javah tool is deprecated as of JDK 9 and might be removed in a future JDK release. The tool has been superseded by the
-h option added to
javac in JDK 8.
javah [options] fully-qualified-class-name ...
The command-line options. See Options for javah.
The fully qualified location of the classes to be converted to C header and source files.
Each class must be specified by its fully qualified name, optionally prefixed by a module name followed by /. For example:
javah command 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 with a layout that 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. When the class passed to the
javah command is inside a package, the package name is added to the beginning of both the header file name and the structure name. Underscores (_) are used as name delimiters.
By default the
javah command 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 Java Native Interface (JNI) doesn’t require header information or stub files. The
javah command can still be used to generate native method function prototypes needed for JNI-style native methods. The
javah command produces JNI-style output and places the result in the
Options for javah
In tools that support
-- style options, the GNU-style options can use
= instead of a whitespace to separate the name of an option from its value.
Concatenates the resulting header or source files for all the classes listed on the command line into an output file. Only one of
-d can be used.
Sets the directory where the
javah command saves the header files or the stub files. Only one of
-o can be used.
Indicates verbose output and causes the
javah command to print a message to
stdout about the status of the generated files.
Prints a help message for
javah command release information.
javah command to create an output file containing JNI-style native method function prototypes. This is the default output; use of
-jni is optional.
Specifies that output files should always be written.
Path from which to load application modules.
Specify where to find system modules.
-classpath path, or
Specifies the path the
javah command uses to look up classes. Overrides the default or the
CLASSPATH environment variable when it is set. Directories are separated by colons on Oracle Solaris and semicolons on Windows. The general format for path is:
Oracle Solaris, Linux, OS X:
As a special convenience, a class path element that contains a base name of
* is considered equivalent to specifying a list of all the files in the directory with the extension
For example, if directory
b.JAR, then the class path element
mydir/* is expanded to
a.jar:b.JAR, except that the order of JAR files is unspecified. All JAR files in the specified directory, including hidden ones, are included in the list. A class path entry that consists of
* expands to a list of all the JAR files in the current directory. The
CLASSPATH environment variable, where defined, is similarly expanded. Any class path wild card expansion occurs before the Java Virtual Machine (JVM) is started. A Java program never sees unexpanded wild cards except by querying the environment. For example, by calling
Specifies the path from which to load bootstrap classes.