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