1javah(1) General Commands Manual javah(1)
2
3
4
6 javah - C Header and Stub File Generator
7
8 javah produces C header files and C source files from a Java class.
9 These files provide the connective glue that allow your Java and C code
10 to interact.
11
13 javah [ options ] fully-qualified-classname. . .
14 javah_g [ options ] fully-qualified-classname. . .
15
16
18 javah generates C header and source files that are needed to implement
19 native methods. The generated header and source files are used by C
20 programs to reference an object's instance variables from native source
21 code. The .h file contains a struct definition whose layout parallels
22 the layout of the corresponding class. The fields in the struct corre‐
23 spond to instance variables in the class.
24
25 The name of the header file and the structure declared within it are
26 derived from the name of the class. If the class passed to javah is
27 inside a package, the package name is prepended to both the header file
28 name and the structure name. Underscores (_) are used as name delim‐
29 iters.
30
31 By default javah creates a header file for each class listed on the
32 command line and puts the files in the current directory. Use the
33 -stubs option to create source files. Use the -o option to concatenate
34 the results for all listed classes into a single file.
35
36 The new native method interface, Java Native Interface (JNI), does not
37 require header information or stub files. javah can still be used to
38 generate native method function proptotypes needed for JNI-style native
39 methods. javah produces JNI-style output by default, and places the
40 result in the .h file.
41
42 javah_g is a non-optimized version of javah suitable for use with
43 debuggers like jdb.
44
46 -o outputfile
47 Concatenates the resulting header or source files for all the
48 classes listed on the command line into outputfile. Only one of -o
49 or -d may be used.
50
51 -d directory
52 Sets the directory where javah saves the header files or the stub
53 files. Only one of -d or -o may be used.
54
55 -stubs
56 Causes javah to generate C declarations from the Java object file.
57
58 -verbose
59 Indicates verbose output and causes javah to print a message to std‐
60 out concerning the status of the generated files.
61
62 -help
63 Print help message for javah usage.
64
65 -version
66 Print out javah version information.
67
68 -jni
69 Causes javah to create an output file containing JNI-style native
70 method function prototypes. This is the default output, so use of
71 -jni is optional.
72
73 -classpath path
74 Specifies the path javah uses to look up classes. Overrides the
75 default or the CLASSPATH environment variable if it is set. Directo‐
76 ries are separated by colons. Thus the general format for path is:
77 .:<your_path>
78 For example:
79 .:/home/avh/classes:/usr/local/java/classes
80
81 As a special convenience, a class path element containing a basename of
82 * is considered equivalent to specifying a list of all the files in the
83 directory with the extension .jar or .JAR (a java program cannot tell
84 the difference between the two invocations).
85 For example, if directory foo contains a.jar and b.JAR, then the class
86 path element foo/* is expanded to a A.jar:b.JAR, except that the order
87 of jar files is unspecified. All jar files in the specified directory,
88 even hidden ones, are included in the list. A classpath entry consist‐
89 ing simply of * expands to a list of all the jar files in the current
90 directory. The CLASSPATH environment variable, where defined, will be
91 similarly expanded. Any classpath wildcard expansion occurs before the
92 Java virtual machine is started -- no Java program will ever see unex‐
93 panded wildcards except by querying the environment. For example; by
94 invoking System.getenv("CLASSPATH").
95
96 -bootclasspath path
97 Specifies path from which to load bootstrap classes. By default, the
98 bootstrap classes are the classes implementing the core Java 2 plat‐
99 form located in jre/lib/rt.jar and several other jar files.
100
101 -old
102 Specifies that old JDK1.0-style header files should be generated.
103
104 -force
105 Specifies that output files should always be written.
106
107 -Joption
108 Pass option to the Java virtual machine, where option is one of the
109 options described on the reference page for the java application
110 launcher. For example, -J-Xms48m sets the startup memory to 48
111 megabytes.
112
114 CLASSPATH
115 Used to provide the system a path to user-defined classes. Directo‐
116 ries are separated by colons, for example,
117
118
120 javac, java, jdb, javap, javadoc
121
122 05 Aug 2006 javah(1)