source: release-kits/lirk3/bin/ant-installer/web/manual1.7.0/manual/OptionalTasks/javah.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 7.4 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>Javah Task</title>
23</head>
24
25<body>
26
27<h2><a name="javah">Javah</a></h2>
28<h3>Description</h3>
29<p>Generates JNI headers from a Java class.</p>
30<p> When this task executes, it will generate the C header and source files that
31are needed to implement native methods. JNI operates differently depending on
32whether <a href="http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javah.html">JDK1.2</a>
33(or later) or <a href="http://java.sun.com/products/jdk/1.1/docs/tooldocs/win32/javah.html">pre-JDK1.2</a>
34systems are used.</p>
35
36<p>It is possible to use different compilers. This can be selected
37with the <code>implementation</code> attribute. <a
38name="implementationvalues">Here are the choices</a>:</p>
39<ul>
40 <li>default - the default compiler (kaffeh or sun) for the platform.</li>
41 <li>sun (the standard compiler of the JDK)</li>
42 <li>kaffeh (the native standard compiler of <a href="http://www.kaffe.org" target="_top">Kaffe</a>)</li>
43</ul>
44
45<h3>Parameters</h3>
46<table border="1" cellpadding="2" cellspacing="0">
47 <tr>
48 <td valign="top"><b>Attribute</b></td>
49 <td valign="top"><b>Description</b></td>
50 <td valign="top" align="center"><b>Required</b></td>
51 </tr>
52 <tr>
53 <td valign="top">class</td>
54 <td valign="top">the fully-qualified name of the class (or classes,
55 separated by commas)</td>
56 <td align="center" valign="top">Yes</td>
57 </tr>
58 <tr>
59 <td valign="top">outputFile</td>
60 <td valign="top">concatenates the resulting header or source files for all the classes listed into this file</td>
61 <td align="center" valign="middle" rowspan="2">Yes</td>
62 </tr>
63 <tr>
64 <td valign="top">destdir</td>
65 <td valign="top">sets the directory where javah saves the header files or the
66 stub files.</td>
67 </tr>
68 <tr>
69 <td valign="top">force</td>
70 <td valign="top">specifies that output files should always be written (JDK1.2 only)</td>
71 <td valign="top" align="center">No</td>
72 </tr>
73 <tr>
74 <td valign="top">old</td>
75 <td valign="top">specifies that old JDK1.0-style header files should be generated
76 (otherwise output file contain JNI-style native method function prototypes) (JDK1.2 only)</td>
77 <td valign="top" align="center">No</td>
78 </tr>
79 <tr>
80 <td valign="top">stubs</td>
81 <td valign="top">generate C declarations from the Java object file (used with old)</td>
82 <td valign="top" align="center">No</td>
83 </tr>
84 <tr>
85 <td valign="top">verbose</td>
86 <td valign="top">causes Javah to print a message concerning the status of the generated files</td>
87 <td valign="top" align="center">No</td>
88 </tr>
89 <tr>
90 <td valign="top">classpath</td>
91 <td valign="top">the classpath to use.</td>
92 <td align="center" valign="top">No</td>
93 </tr>
94 <tr>
95 <td valign="top">bootclasspath</td>
96 <td valign="top">location of bootstrap class files.</td>
97 <td valign="top" align="center">No</td>
98 </tr>
99 <tr>
100 <td valign="top">extdirs</td>
101 <td valign="top"> location of installed extensions.</td>
102 <td valign="top" align="center">No</td>
103 </tr>
104 <tr>
105 <td valign="top">implementation</td>
106 <td valign="top">The compiler implementation to use. If this
107 attribute is not set, the default compiler for the current VM
108 will be used. (See the above <a
109 href="#implementationvalues">list</a> of valid compilers.)</td>
110 <td align="center" valign="top">No</td>
111 </tr>
112</table>
113<p>Either outputFile or destdir must be supplied, but not both.&nbsp;</p>
114
115<h3>Parameters specified as nested elements</h3>
116
117<h4>arg</h4>
118
119<p>You can specify additional command line arguments for the compiler
120with nested <code>&lt;arg&gt;</code> elements. These elements are
121specified like <a href="../using.html#arg">Command-line Arguments</a>
122but have an additional attribute that can be used to enable arguments
123only if a given compiler implementation will be used.</p>
124
125<table border="1" cellpadding="2" cellspacing="0">
126<tr>
127 <td width="12%" valign="top"><b>Attribute</b></td>
128 <td width="78%" valign="top"><b>Description</b></td>
129 <td width="10%" valign="top"><b>Required</b></td>
130</tr>
131 <tr>
132 <td valign="top">value</td>
133 <td align="center" rowspan="4">See
134 <a href="../using.html#arg">Command-line Arguments</a>.</td>
135 <td align="center" rowspan="4">Exactly one of these.</td>
136 </tr>
137 <tr>
138 <td valign="top">line</td>
139 </tr>
140 <tr>
141 <td valign="top">file</td>
142 </tr>
143 <tr>
144 <td valign="top">path</td>
145 </tr>
146 <tr>
147 <td valign="top">implementation</td>
148 <td>Only pass the specified argument if the chosen compiler
149 implementation matches the value of this attribute. Legal values
150 are the same as those in the above <a
151 href="#implementationvalues">list</a> of valid compilers.)</td>
152 <td align="center">No</td>
153 </tr>
154</table>
155
156<h3>Examples</h3>
157<pre> &lt;javah destdir=&quot;c&quot; class=&quot;org.foo.bar.Wibble&quot;/&gt;</pre>
158<p>makes a JNI header of the named class, using the JDK1.2 JNI model. Assuming
159the directory 'c' already exists, the file <tt>org_foo_bar_Wibble.h</tt>
160is created there. If this file already exists, it is left unchanged.</p>
161<pre> &lt;javah outputFile=&quot;wibble.h&quot;&gt;
162 &lt;class name=&quot;org.foo.bar.Wibble,org.foo.bar.Bobble&quot;/&gt;
163 &lt;/javah&gt;</pre>
164<p>is similar to the previous example, except the output is written to a file
165called <tt>wibble.h</tt>
166in the current directory.</p>
167<pre> &lt;javah destdir=&quot;c&quot; force=&quot;yes&quot;&gt;
168 &lt;class name=&quot;org.foo.bar.Wibble&quot;/&gt;
169 &lt;class name=&quot;org.foo.bar.Bobble&quot;/&gt;
170 &lt;class name=&quot;org.foo.bar.Tribble&quot;/&gt;
171 &lt;/javah&gt;</pre>
172<p>writes three header files, one for each of the classes named. Because the
173force option is set, these header files are always written when the Javah task
174is invoked, even if they already exist.</p>
175<pre> &lt;javah destdir=&quot;c&quot; verbose=&quot;yes&quot; old=&quot;yes&quot; force=&quot;yes&quot;&gt;
176 &lt;class name=&quot;org.foo.bar.Wibble&quot;/&gt;
177 &lt;class name=&quot;org.foo.bar.Bobble&quot;/&gt;
178 &lt;class name=&quot;org.foo.bar.Tribble&quot;/&gt;
179 &lt;/javah&gt;
180 &lt;javah destdir=&quot;c&quot; verbose=&quot;yes&quot; stubs=&quot;yes&quot; old=&quot;yes&quot; force=&quot;yes&quot;&gt;
181 &lt;class name=&quot;org.foo.bar.Wibble&quot;/&gt;
182 &lt;class name=&quot;org.foo.bar.Bobble&quot;/&gt;
183 &lt;class name=&quot;org.foo.bar.Tribble&quot;/&gt;
184 &lt;/javah&gt;</pre>
185<p>writes the headers for the three classes using the 'old' JNI format, then
186writes the corresponding .c stubs. The verbose option will cause Javah to
187describe its progress.</p>
188
189
190</body>
191
192</html>
Note: See TracBrowser for help on using the repository browser.