/plugins/JCompiler/tags/jcompiler_1_3_3/index.html

# · HTML · 423 lines · 334 code · 87 blank · 2 comment · 0 complexity · 0ad20656add479e1cc5f08a70eda7941 MD5 · raw file

  1. <html>
  2. <!-- jEdit options: -->
  3. <!-- :tabSize=8:indentSize=2:noTabs=true:maxLineLen=80: -->
  4. <title>Java Compiler</title>
  5. <body>
  6. <h1>Java Compiler</h1><p>
  7. Copyright (c) 1999, 2000 by Kevin A. Burton and Aziz Sharif.<br>
  8. Modified by Dominic Stolerman, Logan Bauer, Mike Hansen, and Dirk M&ouml;bius.<p>
  9. Current maintainer: Dirk M&ouml;bius
  10. (<a href="mailto:dmoebius@gmx.net">dmoebius@gmx.net</a>)<p>
  11. <ol>
  12. <li><a href="#requirements">Requirements</a></li>
  13. <li><a href="#installation">Installation</a></li>
  14. <li><a href="#usage">Usage</a></li>
  15. <li><a href="#options">Options</a></li>
  16. <li><a href="#troubleshooting">Troubleshooting</a></li>
  17. <li><a href="#compiler">Compiler Versions</a></li>
  18. </ol>
  19. <a name="requirements"></a>
  20. <h2>1. Requirements</h2>
  21. <ul>
  22. <li>jEdit &gt;= 3.2.2</li>
  23. <li>plugin EditBus &gt;= 1.1</li>
  24. <li>plugin Console &gt;= 3.0</li>
  25. <li>a Java Development Kit (JDK) &gt;= 1.1, <b>not</b> a Java Runtime
  26. Environment (JRE) !</li>
  27. </ul>
  28. <b>Note:</b> The installation of Console also forces you to install the
  29. ErrorList plugin, which is a good thing. It provides one-click access to
  30. error positions, and highlightening of compilation errors in the edit pane with
  31. wavy red lines.<p>
  32. <a name="installation"></a>
  33. <h2>2. Installation</h2>
  34. You should use jEdit's PluginManager to install the Java Compiler plugin.
  35. (Since you're reading this, I assume you have already done this).<p>
  36. <a name="usage"></a>
  37. <h2>3. Usage</h2>
  38. <h3>3.1 Menu actions</h3>
  39. Java Compiler has 4 menu actions in menu <b>Plugins&gt;Java Compiler</b>:
  40. <ul>
  41. <li>
  42. <b>Compile File</b><p>
  43. Compiles the file currently being edited.<p>
  44. </li>
  45. <li>
  46. <b>Build Package(s)</b><p>
  47. Builds the whole source tree where the current file is in.<br>
  48. Java Compiler tries to find out the package the current file is in by
  49. parsing for the keyword <code>package</code>. Then it goes to
  50. it's root directory and compiles all java files in the root directory and
  51. all subdirectories below. It does a smart compile in that if the source
  52. file is not newer than the class file, then it doesn't recompile it.<p>
  53. </li>
  54. <li>
  55. <b>Rebuild Package(s)</b><p>
  56. Same as "Build Package(s)", but always compiles every file.<p>
  57. </li>
  58. <li>
  59. <b>Java Compiler options...</b><p>
  60. A shortcut to <b>Utilities&gt;Global Options&gt;Plugins&gt;Java Compiler.</b>
  61. </li>
  62. </ul>
  63. <h3>3.2 Commands</h3>
  64. The Java Compiler shell in the Console plugin understands the following
  65. commands:
  66. <ul>
  67. <li>
  68. <b>compile</b><p>
  69. Same as the <b>Compile File</b> menu action. See above.<p>
  70. </li>
  71. <li>
  72. <b>compilepkg</b><p>
  73. Same as the <b>Build Package(s)</b> menu action. See above.<p>
  74. </li>
  75. <li>
  76. <b>rebuildpkg</b><p>
  77. Same as the <b>Rebuilds Package(s)</b> menu action. See above.<p>
  78. </li>
  79. <li>
  80. <b>javac [options] files...</b><p>
  81. Invokes the javac compiler with the specified options and files. As
  82. with all other commands, the javac compiler is invoked in the same
  83. Virtual Machine as jEdit runs in.<br>
  84. Accepts the same options as the native <code>javac</code> binary
  85. executable. Enter "<code>javac -h</code>" for a list of options.<br>
  86. Note that no native process gets spawned if this javac command is
  87. used.<p>
  88. </li>
  89. <li>
  90. <b>help</b><p>
  91. Displays a short explanation of the commands.<p>
  92. </li>
  93. </ul>
  94. <a name="options"></a>
  95. <h2>4. Options</h2>
  96. You may configure some options in
  97. <b>Utilities&gt;Global&nbsp;Options&gt;Plugin&nbsp;Options&gt;Java&nbsp;Compiler</b>.
  98. Most of them are self explaining, but some need special explanation:
  99. <h3>4.1 General options</h3>
  100. <ul>
  101. <li>
  102. <b>Regexp for errors</b><p>
  103. Java Compiler uses this regular expression to identify error messages,
  104. which are then sent to the <i>ErrorList</i> plugin, if installed.
  105. The regular expression should contain three groups which can be
  106. referenced by $1, $2 and $3 in the three fields below.
  107. See the <i>jEdit Users Guide</i> for help on regular expressions.<p>
  108. The default is: <code>(.+):(\d+):(.+)</code><p>
  109. </li>
  110. <li>
  111. <b>Regexp for warnings</b><p>
  112. If a line of compiler output has been identified as error message by the
  113. regular expression above, Java Compiler uses this regular expression to
  114. decide whether it is a warning message or not. In the <i>ErrorList</i>
  115. plugin, warning messages are marked with a yellow traffic light instead of
  116. a red one.<p>
  117. The default is: <code>.+(note|warning|caution):.+</code><p>
  118. </li>
  119. <li>
  120. <b>Parse errors for ^ column indicator</b><p>
  121. Sun's Java compilers indicate error column positions by a single line
  122. containing '^'. Example:<p>
  123. <pre>
  124. home\dirk\jcompiler\Compiler.java:33:
  125. Public class jcompiler.JCompiler must be defined in
  126. a file called "JCompiler.java".
  127. public class JCompiler implements EBComponent {
  128. ^
  129. </pre>
  130. If you check this option, Java Compiler parses the compiler
  131. output for these lines. The column position information is used in the
  132. <i>ErrorList</i> plugin to highlight errors in the source code with
  133. wavy lines.<p>
  134. This option is on per default.<p>
  135. </ul>
  136. <h3>4.2 Compiler options</h3>
  137. <ul>
  138. <li>
  139. <b>Use modern compiler (JDK 1.3 or higher)</b><p>
  140. If checked, the new compiler shipped with JDK 1.3 is used. Otherwise, the
  141. old compiler is used. See <a href="#compiler">below</a> for an
  142. explanation.<p>
  143. </li>
  144. <li>
  145. <b>Required library path</b><p>
  146. One or more directories that will be scanned for JAR/ZIP libraries.
  147. All found libraries will be added automatically to the classpath.<p>
  148. If you specify more than one directory, separated them by the Java path
  149. separator, like in $CLASSPATH. Examples:<p>
  150. Unix: "<tt>/usr/local/java/lib:/usr/share/java/lib</tt>" or <br>
  151. Windows: "<tt>C:\Software\Java\libs;C:\Java\Programming\libraries</tt>"<p>
  152. </li>
  153. <li>
  154. <b>Source path</b><p>
  155. This sets the "-sourcepath" option for the compiler. Available only on JDK
  156. versions 1.2 or higher.<p>
  157. </li>
  158. <li>
  159. <b>$basepath</b><p>
  160. Set the <tt>$basepath</tt> variable to the base directory of your project.
  161. Use this variable in the classpath, sourcepath, required library path and
  162. output directory option, e.g.:<p>
  163. <blockquote>
  164. $basepath = "<tt>c:\My Files\My Projects\TinyFishProject</tt>"<br>
  165. Class path = "<tt>$<em>basepath</em>\classes</tt>"<br>
  166. Source path = "<tt>$<em>basepath</em>\src</tt>"<br>
  167. Required library path = "<tt>$<em>basepath</em>\lib</tt>"<br>
  168. Output directory = "<tt>$<em>basepath</em>\classes</tt>"<br>
  169. </blockquote><p>
  170. <em>PS: I know, this feature screams for proper project managing,
  171. e.g. </em>project files<em>. Someday the ProjectManager plugin will be
  172. ready to do this. Have patience and faith, please.</em> {:-} <p>
  173. </li>
  174. </ul>
  175. <a name="troubleshooting"></a>
  176. <h2>5. Troubleshooting</h2>
  177. <h3>Upon startup, I get an error saying that <tt>tools.jar</tt> cannot be
  178. found!</h3>
  179. This error should occur only on JDK 1.2 or higher.<p>
  180. <tt>tools.jar</tt> is a Java system library, provided by Sun,
  181. that contains the Java compiler, among other things. It is usually installed in
  182. <tt><i>jdkhome</i>/lib/</tt>, where <tt><i>jdkhome</i></tt> denotes the
  183. JDK installation directory.<p>
  184. JCompiler searched for this library, but couldn't find it. Please search for
  185. this library manually, and configure your JDK to find the library. You must
  186. do this, <i>before</i> jEdit is started.
  187. The easiest way to do this is to copy <tt>tools.jar</tt> to the right place.
  188. That is, copy <tt>tools.jar</tt> to:
  189. <blockquote>
  190. <tt><i>jdkhome</i>/jre/lib/ext/</tt>
  191. </blockquote><p>
  192. That way, the JDK will find the library automatically, and you don't have to
  193. configure anything else.
  194. If, for any reason, you cannot copy the library (maybe because you don't have
  195. write access to the JDK installation directory), you have a lot of
  196. alternatives:
  197. <ul>
  198. <li>
  199. <b>Copy <code>tools.jar</code> to <i>home</i>/.jedit/jars/,</b><br>
  200. where <i>home</i> denotes your user home. The following table shows
  201. the location of your user home:<p>
  202. <table border="1">
  203. <tr bgcolor="#E0E0E0">
  204. <td>Operating system</td>
  205. <td>Directory <i>home</i></td>
  206. </tr>
  207. <tr>
  208. <td>Windows 95,98,ME</td>
  209. <td>C:\WINDOWS\</td>
  210. </tr>
  211. <tr>
  212. <td>Windows NT</td>
  213. <td>C:\WINNT\profiles\<i>&lt;username&gt;</i>\</td>
  214. </tr>
  215. <tr>
  216. <td>Unix</td>
  217. <td>$HOME</td>
  218. </tr>
  219. <tr>
  220. <td>Macintosh</td>
  221. <td>??? (please tell me)</td>
  222. </tr>
  223. </table><br>
  224. Using this alternative has the same effect as copying to
  225. <i>jdkhome</i>/jre/lib/ext/, but you run into difficulties, if you
  226. switch back to JDK 1.1 later on.<p>
  227. </li>
  228. <li>
  229. <b>Change the CLASSPATH that is used when jEdit is started.</b><p>
  230. <table border="1">
  231. <tr bgcolor="#E0E0E0">
  232. <td>Operating system</td>
  233. <td>Example</td>
  234. </tr>
  235. <tr>
  236. <td>Windows</td>
  237. <td><code>-classpath "%CLASSPATH%;<br><u><i>jdkhome</i>\lib\tools.jar;</u>C:\Programm&nbsp;Files\jEdit\jedit.jar"</code></td>
  238. </tr>
  239. <tr>
  240. <td>Unix</td>
  241. <td><code>-classpath "$CLASSPATH:<br><u><i>jdkhome</i>/lib/tools.jar:</u>/usr/local/jEdit/3.0/jedit.jar"</code></td>
  242. </tr>
  243. </table><br>
  244. </li>
  245. </ul>
  246. <a name="compiler"></a>
  247. <h2>6. Compiler Versions</h2>
  248. <h3>6.1 The modern compiler</h3>
  249. Starting with version 1.3, Sun shipped a new compiler with the JDK. From the
  250. Sun documentation:
  251. <blockquote><em>
  252. The <b>javac</b> compiler has been completely re-implemented in version 1.3
  253. of the Java 2 SDK. The compiler implementation from previous releases of the
  254. SDK is still available as <b>oldjavac</b>. The new javac is faster than the
  255. old javac.<p>
  256. The nonstandard options, those prefixed with '-X', are no longer supported.
  257. In particular, the <code>-Xdepend</code> option is no longer available.<p>
  258. When searching the classpath or sourcepath, the new compiler does not follow
  259. symbolic links. In version 1.3, it is therefore necessary to avoid the use of
  260. symbolic links within the directories appearing on the classpath and
  261. sourcepath, and within their subdirectories.<p>
  262. When the new 1.3 compiler detects an error in a source file during a
  263. compilation, it continues to parse the remaining source files and attempts to
  264. identify any further errors that they may contain. Code generation is
  265. completely suppressed for the remainder of the compilation, however, and no
  266. class files will be generated, even for compilation units that contain no
  267. errors. The old compiler in 1.2 would generate class files for any compilation
  268. units that did not contain errors. This resulted in less redundant work during
  269. the repeated compilations required to identify and correct all errors in a
  270. large program containing many files with errors. We hope to improve this
  271. behavior in the future. The new compiler is substantially faster overall,
  272. however, which should tend to offset this somewhat.
  273. </em></blockquote><p>
  274. If you have JDK 1.3 or higher, you can enable the modern compiler with the
  275. option <b>Use modern compiler</b> on the <b>Compiler options</b> dialog.
  276. <h3>6.2 Internals</h3>
  277. In case you're interested: the following classes get used when invoking the
  278. compiler:
  279. <h4>6.2.1 Classic compiler</h4>
  280. <font size="-1">
  281. &nbsp;&nbsp;&nbsp;&nbsp;<b>package</b> sun.tools.javac;<br>
  282. &nbsp;&nbsp;&nbsp;&nbsp;<br>
  283. &nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <b>class</b> <u>Main</u><br>
  284. &nbsp;&nbsp;&nbsp;&nbsp;{<br>
  285. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>/**<br>
  286. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Create a new compiler instance.<br>
  287. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@param</b> <code>output</code> where compiler and error messages should go.<br>
  288. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@param</b> <code>program</code> should always be "javac".<br>
  289. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br></em>
  290. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <u>Main</u>(OutputStream output, String program);<br>
  291. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
  292. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>/**<br>
  293. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Compile files.<br>
  294. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@param</b> <code>arguments</code> the command line options and files.<br>
  295. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@return</b> <code>true</code> if no error occured.<br>
  296. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br></em>
  297. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <b>boolean</b> <u>compile</u>(String[] arguments);<br>
  298. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
  299. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>/**<br>
  300. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Return the exit status of the last compile run.<br>
  301. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@return</b> 0 for EXIT_OK, 1 for EXIT_ERROR, 2 for EXIT_CMDERR,<br>
  302. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* &nbsp;&nbsp;3 for EXIT_SYSERR, 4 for EXIT_ABNORMAL.<br>
  303. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br></em>
  304. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <b>int</b> <u>getExitStatus</u>();<br>
  305. &nbsp;&nbsp;&nbsp;&nbsp;}<br>
  306. </font>
  307. <h4>6.2.2 Modern compiler</h4>
  308. <font size="-1">
  309. &nbsp;&nbsp;&nbsp;&nbsp;<b>package</b> com.sun.tools.javac;<br>
  310. &nbsp;&nbsp;&nbsp;&nbsp;<br>
  311. &nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <b>class</b> <u>Main</u><br>
  312. &nbsp;&nbsp;&nbsp;&nbsp;{<br>
  313. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>/**<br>
  314. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Create a new compiler instance.<br>
  315. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Compiler output and errors go to <code>System.out</code> and <code>System.err</code>.<br>
  316. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br></em>
  317. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <u>Main</u>();<br>
  318. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
  319. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>/**<br>
  320. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Compile files.<br>
  321. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@param</b> <code>arguments</code> the command line options and files.<br>
  322. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* <b>@return</b> the exit status of the compile run: 0 for EXIT_OK,<br>
  323. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* &nbsp;&nbsp;1 for EXIT_ERROR, 2 for EXIT_CMDERR, 3 for EXIT_SYSERR,<br>
  324. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* &nbsp;&nbsp;4 for EXIT_ABNORMAL.<br>
  325. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br></em>
  326. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>public</b> <b>int</b> <u>compile</u>(String[] arguments);<br>
  327. &nbsp;&nbsp;&nbsp;&nbsp;}<br>
  328. </font>
  329. <br>
  330. <br><hr>
  331. <font size="-1">
  332. The current maintainer of the Java Compiler plugin is Dirk M&ouml;bius
  333. (<a href="mailto:dmoebius@gmx.net">dmoebius@gmx.net</a>).
  334. </font>
  335. </body>
  336. </html>