/plugins/JCompiler/tags/jcompiler_1_3_3/index.html
# · HTML · 423 lines · 334 code · 87 blank · 2 comment · 0 complexity · 0ad20656add479e1cc5f08a70eda7941 MD5 · raw file
- <html>
- <!-- jEdit options: -->
- <!-- :tabSize=8:indentSize=2:noTabs=true:maxLineLen=80: -->
- <title>Java Compiler</title>
- <body>
- <h1>Java Compiler</h1><p>
- Copyright (c) 1999, 2000 by Kevin A. Burton and Aziz Sharif.<br>
- Modified by Dominic Stolerman, Logan Bauer, Mike Hansen, and Dirk Möbius.<p>
- Current maintainer: Dirk Möbius
- (<a href="mailto:dmoebius@gmx.net">dmoebius@gmx.net</a>)<p>
- <ol>
- <li><a href="#requirements">Requirements</a></li>
- <li><a href="#installation">Installation</a></li>
- <li><a href="#usage">Usage</a></li>
- <li><a href="#options">Options</a></li>
- <li><a href="#troubleshooting">Troubleshooting</a></li>
- <li><a href="#compiler">Compiler Versions</a></li>
- </ol>
- <a name="requirements"></a>
- <h2>1. Requirements</h2>
- <ul>
- <li>jEdit >= 3.2.2</li>
- <li>plugin EditBus >= 1.1</li>
- <li>plugin Console >= 3.0</li>
- <li>a Java Development Kit (JDK) >= 1.1, <b>not</b> a Java Runtime
- Environment (JRE) !</li>
- </ul>
- <b>Note:</b> The installation of Console also forces you to install the
- ErrorList plugin, which is a good thing. It provides one-click access to
- error positions, and highlightening of compilation errors in the edit pane with
- wavy red lines.<p>
- <a name="installation"></a>
- <h2>2. Installation</h2>
- You should use jEdit's PluginManager to install the Java Compiler plugin.
- (Since you're reading this, I assume you have already done this).<p>
- <a name="usage"></a>
- <h2>3. Usage</h2>
- <h3>3.1 Menu actions</h3>
- Java Compiler has 4 menu actions in menu <b>Plugins>Java Compiler</b>:
- <ul>
- <li>
- <b>Compile File</b><p>
- Compiles the file currently being edited.<p>
- </li>
- <li>
- <b>Build Package(s)</b><p>
- Builds the whole source tree where the current file is in.<br>
- Java Compiler tries to find out the package the current file is in by
- parsing for the keyword <code>package</code>. Then it goes to
- it's root directory and compiles all java files in the root directory and
- all subdirectories below. It does a smart compile in that if the source
- file is not newer than the class file, then it doesn't recompile it.<p>
- </li>
- <li>
- <b>Rebuild Package(s)</b><p>
- Same as "Build Package(s)", but always compiles every file.<p>
- </li>
- <li>
- <b>Java Compiler options...</b><p>
- A shortcut to <b>Utilities>Global Options>Plugins>Java Compiler.</b>
- </li>
- </ul>
- <h3>3.2 Commands</h3>
- The Java Compiler shell in the Console plugin understands the following
- commands:
- <ul>
- <li>
- <b>compile</b><p>
- Same as the <b>Compile File</b> menu action. See above.<p>
- </li>
- <li>
- <b>compilepkg</b><p>
- Same as the <b>Build Package(s)</b> menu action. See above.<p>
- </li>
- <li>
- <b>rebuildpkg</b><p>
- Same as the <b>Rebuilds Package(s)</b> menu action. See above.<p>
- </li>
- <li>
- <b>javac [options] files...</b><p>
- Invokes the javac compiler with the specified options and files. As
- with all other commands, the javac compiler is invoked in the same
- Virtual Machine as jEdit runs in.<br>
- Accepts the same options as the native <code>javac</code> binary
- executable. Enter "<code>javac -h</code>" for a list of options.<br>
- Note that no native process gets spawned if this javac command is
- used.<p>
- </li>
- <li>
- <b>help</b><p>
- Displays a short explanation of the commands.<p>
- </li>
- </ul>
- <a name="options"></a>
- <h2>4. Options</h2>
- You may configure some options in
- <b>Utilities>Global Options>Plugin Options>Java Compiler</b>.
- Most of them are self explaining, but some need special explanation:
- <h3>4.1 General options</h3>
- <ul>
- <li>
- <b>Regexp for errors</b><p>
- Java Compiler uses this regular expression to identify error messages,
- which are then sent to the <i>ErrorList</i> plugin, if installed.
- The regular expression should contain three groups which can be
- referenced by $1, $2 and $3 in the three fields below.
- See the <i>jEdit Users Guide</i> for help on regular expressions.<p>
- The default is: <code>(.+):(\d+):(.+)</code><p>
- </li>
- <li>
- <b>Regexp for warnings</b><p>
- If a line of compiler output has been identified as error message by the
- regular expression above, Java Compiler uses this regular expression to
- decide whether it is a warning message or not. In the <i>ErrorList</i>
- plugin, warning messages are marked with a yellow traffic light instead of
- a red one.<p>
- The default is: <code>.+(note|warning|caution):.+</code><p>
- </li>
- <li>
- <b>Parse errors for ^ column indicator</b><p>
- Sun's Java compilers indicate error column positions by a single line
- containing '^'. Example:<p>
- <pre>
- home\dirk\jcompiler\Compiler.java:33:
- Public class jcompiler.JCompiler must be defined in
- a file called "JCompiler.java".
- public class JCompiler implements EBComponent {
- ^
- </pre>
- If you check this option, Java Compiler parses the compiler
- output for these lines. The column position information is used in the
- <i>ErrorList</i> plugin to highlight errors in the source code with
- wavy lines.<p>
- This option is on per default.<p>
- </ul>
- <h3>4.2 Compiler options</h3>
- <ul>
- <li>
- <b>Use modern compiler (JDK 1.3 or higher)</b><p>
- If checked, the new compiler shipped with JDK 1.3 is used. Otherwise, the
- old compiler is used. See <a href="#compiler">below</a> for an
- explanation.<p>
- </li>
- <li>
- <b>Required library path</b><p>
- One or more directories that will be scanned for JAR/ZIP libraries.
- All found libraries will be added automatically to the classpath.<p>
- If you specify more than one directory, separated them by the Java path
- separator, like in $CLASSPATH. Examples:<p>
- Unix: "<tt>/usr/local/java/lib:/usr/share/java/lib</tt>" or <br>
- Windows: "<tt>C:\Software\Java\libs;C:\Java\Programming\libraries</tt>"<p>
- </li>
- <li>
- <b>Source path</b><p>
- This sets the "-sourcepath" option for the compiler. Available only on JDK
- versions 1.2 or higher.<p>
- </li>
- <li>
- <b>$basepath</b><p>
- Set the <tt>$basepath</tt> variable to the base directory of your project.
- Use this variable in the classpath, sourcepath, required library path and
- output directory option, e.g.:<p>
- <blockquote>
- $basepath = "<tt>c:\My Files\My Projects\TinyFishProject</tt>"<br>
- Class path = "<tt>$<em>basepath</em>\classes</tt>"<br>
- Source path = "<tt>$<em>basepath</em>\src</tt>"<br>
- Required library path = "<tt>$<em>basepath</em>\lib</tt>"<br>
- Output directory = "<tt>$<em>basepath</em>\classes</tt>"<br>
- </blockquote><p>
- <em>PS: I know, this feature screams for proper project managing,
- e.g. </em>project files<em>. Someday the ProjectManager plugin will be
- ready to do this. Have patience and faith, please.</em> {:-} <p>
- </li>
- </ul>
- <a name="troubleshooting"></a>
- <h2>5. Troubleshooting</h2>
- <h3>Upon startup, I get an error saying that <tt>tools.jar</tt> cannot be
- found!</h3>
- This error should occur only on JDK 1.2 or higher.<p>
- <tt>tools.jar</tt> is a Java system library, provided by Sun,
- that contains the Java compiler, among other things. It is usually installed in
- <tt><i>jdkhome</i>/lib/</tt>, where <tt><i>jdkhome</i></tt> denotes the
- JDK installation directory.<p>
- JCompiler searched for this library, but couldn't find it. Please search for
- this library manually, and configure your JDK to find the library. You must
- do this, <i>before</i> jEdit is started.
- The easiest way to do this is to copy <tt>tools.jar</tt> to the right place.
- That is, copy <tt>tools.jar</tt> to:
- <blockquote>
- <tt><i>jdkhome</i>/jre/lib/ext/</tt>
- </blockquote><p>
- That way, the JDK will find the library automatically, and you don't have to
- configure anything else.
- If, for any reason, you cannot copy the library (maybe because you don't have
- write access to the JDK installation directory), you have a lot of
- alternatives:
- <ul>
- <li>
- <b>Copy <code>tools.jar</code> to <i>home</i>/.jedit/jars/,</b><br>
- where <i>home</i> denotes your user home. The following table shows
- the location of your user home:<p>
- <table border="1">
- <tr bgcolor="#E0E0E0">
- <td>Operating system</td>
- <td>Directory <i>home</i></td>
- </tr>
- <tr>
- <td>Windows 95,98,ME</td>
- <td>C:\WINDOWS\</td>
- </tr>
- <tr>
- <td>Windows NT</td>
- <td>C:\WINNT\profiles\<i><username></i>\</td>
- </tr>
- <tr>
- <td>Unix</td>
- <td>$HOME</td>
- </tr>
- <tr>
- <td>Macintosh</td>
- <td>??? (please tell me)</td>
- </tr>
- </table><br>
- Using this alternative has the same effect as copying to
- <i>jdkhome</i>/jre/lib/ext/, but you run into difficulties, if you
- switch back to JDK 1.1 later on.<p>
- </li>
- <li>
- <b>Change the CLASSPATH that is used when jEdit is started.</b><p>
- <table border="1">
- <tr bgcolor="#E0E0E0">
- <td>Operating system</td>
- <td>Example</td>
- </tr>
- <tr>
- <td>Windows</td>
- <td><code>-classpath "%CLASSPATH%;<br><u><i>jdkhome</i>\lib\tools.jar;</u>C:\Programm Files\jEdit\jedit.jar"</code></td>
- </tr>
- <tr>
- <td>Unix</td>
- <td><code>-classpath "$CLASSPATH:<br><u><i>jdkhome</i>/lib/tools.jar:</u>/usr/local/jEdit/3.0/jedit.jar"</code></td>
- </tr>
- </table><br>
- </li>
- </ul>
- <a name="compiler"></a>
- <h2>6. Compiler Versions</h2>
- <h3>6.1 The modern compiler</h3>
- Starting with version 1.3, Sun shipped a new compiler with the JDK. From the
- Sun documentation:
- <blockquote><em>
- The <b>javac</b> compiler has been completely re-implemented in version 1.3
- of the Java 2 SDK. The compiler implementation from previous releases of the
- SDK is still available as <b>oldjavac</b>. The new javac is faster than the
- old javac.<p>
- The nonstandard options, those prefixed with '-X', are no longer supported.
- In particular, the <code>-Xdepend</code> option is no longer available.<p>
- When searching the classpath or sourcepath, the new compiler does not follow
- symbolic links. In version 1.3, it is therefore necessary to avoid the use of
- symbolic links within the directories appearing on the classpath and
- sourcepath, and within their subdirectories.<p>
- When the new 1.3 compiler detects an error in a source file during a
- compilation, it continues to parse the remaining source files and attempts to
- identify any further errors that they may contain. Code generation is
- completely suppressed for the remainder of the compilation, however, and no
- class files will be generated, even for compilation units that contain no
- errors. The old compiler in 1.2 would generate class files for any compilation
- units that did not contain errors. This resulted in less redundant work during
- the repeated compilations required to identify and correct all errors in a
- large program containing many files with errors. We hope to improve this
- behavior in the future. The new compiler is substantially faster overall,
- however, which should tend to offset this somewhat.
- </em></blockquote><p>
- If you have JDK 1.3 or higher, you can enable the modern compiler with the
- option <b>Use modern compiler</b> on the <b>Compiler options</b> dialog.
- <h3>6.2 Internals</h3>
- In case you're interested: the following classes get used when invoking the
- compiler:
- <h4>6.2.1 Classic compiler</h4>
- <font size="-1">
- <b>package</b> sun.tools.javac;<br>
- <br>
- <b>public</b> <b>class</b> <u>Main</u><br>
- {<br>
- <em>/**<br>
- * Create a new compiler instance.<br>
- * <b>@param</b> <code>output</code> where compiler and error messages should go.<br>
- * <b>@param</b> <code>program</code> should always be "javac".<br>
- */<br></em>
- <b>public</b> <u>Main</u>(OutputStream output, String program);<br>
- <br>
- <em>/**<br>
- * Compile files.<br>
- * <b>@param</b> <code>arguments</code> the command line options and files.<br>
- * <b>@return</b> <code>true</code> if no error occured.<br>
- */<br></em>
- <b>public</b> <b>boolean</b> <u>compile</u>(String[] arguments);<br>
- <br>
- <em>/**<br>
- * Return the exit status of the last compile run.<br>
- * <b>@return</b> 0 for EXIT_OK, 1 for EXIT_ERROR, 2 for EXIT_CMDERR,<br>
- * 3 for EXIT_SYSERR, 4 for EXIT_ABNORMAL.<br>
- */<br></em>
- <b>public</b> <b>int</b> <u>getExitStatus</u>();<br>
- }<br>
- </font>
- <h4>6.2.2 Modern compiler</h4>
- <font size="-1">
- <b>package</b> com.sun.tools.javac;<br>
- <br>
- <b>public</b> <b>class</b> <u>Main</u><br>
- {<br>
- <em>/**<br>
- * Create a new compiler instance.<br>
- * Compiler output and errors go to <code>System.out</code> and <code>System.err</code>.<br>
- */<br></em>
- <b>public</b> <u>Main</u>();<br>
- <br>
- <em>/**<br>
- * Compile files.<br>
- * <b>@param</b> <code>arguments</code> the command line options and files.<br>
- * <b>@return</b> the exit status of the compile run: 0 for EXIT_OK,<br>
- * 1 for EXIT_ERROR, 2 for EXIT_CMDERR, 3 for EXIT_SYSERR,<br>
- * 4 for EXIT_ABNORMAL.<br>
- */<br></em>
- <b>public</b> <b>int</b> <u>compile</u>(String[] arguments);<br>
- }<br>
- </font>
- <br>
- <br><hr>
- <font size="-1">
- The current maintainer of the Java Compiler plugin is Dirk Möbius
- (<a href="mailto:dmoebius@gmx.net">dmoebius@gmx.net</a>).
- </font>
- </body>
- </html>