You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

javah.html 6.7 KiB

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