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