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.8 KiB

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