jdt-core-home/howto/batch compile/batchCompile.html
Parent Directory
|
Revision Log
Revision 1.4 -
(download)
(as text)
(annotate)
Sat Jul 10 21:44:50 2004 UTC (5 years, 4 months ago) by oliviert
Branch: MAIN
Changes since 1.3: +164 -46 lines
Sat Jul 10 21:44:50 2004 UTC (5 years, 4 months ago) by oliviert
Branch: MAIN
Changes since 1.3: +164 -46 lines
HEAD - Update how to use the batch compiler with newest options
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]"> <title>How to: Run batch compiler</title> <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css"> </head> <body text="#000000" bgcolor="#FFFFFF"> <table BORDER=0 CELLSPACING=5 CELLPADDING=2 WIDTH="100%" > <tr> <td ALIGN=LEFT VALIGN=TOP COLSPAN="2" BGCOLOR="#0080C0"><b><font color="#FFFFFF">JDT Core / HowTo: Run the Batch Compiler </font></b></td> </tr> <tr> <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> <td WIDTH="98%"><b>Finding the batch compiler</b> <br>The batch compiler class is located in the internal classes of the JDT/Core plugin. So it is in the <i>jdtcore.jar</i> file in the directory <i>plugins/org.eclipse.jdt.core</i>. The name of the class is <i>org.eclipse.jdt.internal.compiler.batch.Main</i>. </td> </tr> <tr> <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> <td WIDTH="98%"><b>Running the batch compiler</b> <ul> <li> Using the main method.</li> <blockquote>Using the main method. The Main class has a main method. This is the classical way to invoke the batch compiler on a command-line. <ul> <li> For example on a command-line:</li> <br><font color="#3366FF">java -classpath jdtcore.jar org.eclipse.jdt.internal.compiler.batch.Main -classpath rt.jar A.java</font> <li> For example in a java source:</li> <br><font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.main(new String[] {"-classpath", "rt.jar", "A.java"});</font></ul> </blockquote> <li> Using the static compile(String) method.</li> <blockquote>The compile(String) method is a convenient method to invoke the batch compiler in a java application. <br>Instead of: <ul> <li> <font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.main(new String[] {"-classpath", "rt.jar", "A.java"});</font></li> <li> you can simply write: <font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.compile("-classpath rt.jar A.java");</font></li> </ul> </blockquote> </ul> </td> </tr> <tr> <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> <td WIDTH="98%"><b>Which options are available?</b> <p> With the orange background, these are suggested options. </p> <blockquote> <table BORDER CELLSPACING=2 CELLPADDING=2 COLS=2 WIDTH="100%" > <tr> <th>Name</th> <th>Usage</th> </tr> <tr> <th colspan="2">Classpath options</th> </tr> <tr> <td valign=top bgcolor="#FFCCAA">-bootclasspath <dir 1>;<dir 2>;...;<dir P></td> <td valign=top bgcolor="#FFCCAA">This is a list of directory or jar files used to bootstrap the class files used by the compiler. By default the libraries of the running VM are used. Entries are separated by the platform path separator.</td> </tr> <tr> <td valign=top bgcolor="#FFCCAA">-cp -classpath <dir 1>;<dir 2>;...;<dir P></td> <td valign=top bgcolor="#FFCCAA">This is a list of directory or jar files used to compile the source files. The default value is the value of the property "java.class.path". Entries are separated by the platform path separator. </td> </tr> <tr> <td valign=top bgcolor="#FFCCAA">-d <dir 1>|none</td> <td bgcolor="#FFCCAA">This is used to specify in which directory the generated .class files should be dumped. If it is omitted, no package directory structure is created.<br> If you don't want to generate .class files, use <font color="#3366FF">-d none</font>.</td> </tr> <tr> <td valign=top>-encoding <encoding name></td> <td>Specify default source encoding format (custom encoding can also be specifed on a per file basis by suffixing each input source file/folder name with <font color="#3366FF">[encoding <encoding name>]</font>).</td> </tr> <tr> <th colspan="2">Compliance options</th> </tr> <tr> <td valign=top>-target 1.1|1.2|1.3|1.4|1.5</td> <td>This specifies the classfile target setting. The possible value are <font color="#3366FF">1.1</font> or <font color="#3366FF">1.2</font>, default is <font color="#3366FF">1.2</font></td> </tr> <tr> <td valign=top>-1.3</td> <td>Set compliance level to <font color="#3366FF">1.3</font>. Implicit -source 1.3 -target 1.1.</td> </tr> <tr> <td valign=top>-1.4</td> <td>Set compliance level to <font color="#3366FF">1.4</font> (default). Implicit -source 1.3 -target 1.2.</td> </tr> <tr> <td valign=top>-1.5</td> <td>Set compliance level to <font color="#3366FF">1.5</font>. Implicit -source 1.5 -target 1.5.</td> </tr> <tr> <td valign=top>-source 1.3|1.4|1.5</td> <td>This is used to enable the assertion support of the compiler. The possible value are: <font color="#3366FF">1.3</font> or <font color="#3366FF">1.4</font>, default is <font color="#3366FF">1.3</font> in <font color="#3366FF">-1.3</font> mode and <font color="#3366FF">1.4</font> in <font color="#3366FF">-1.4</font> mode. In <font color="#3366FF">1.4</font>, <font color="#3366FF"><I>assert</I></font> is treated as a keyword.</td> </tr> <tr> <th colspan="2">Warning options</th> </tr> <tr> <td valign=top>-warn:<blockquote> allDeprecation<br>|allJavadoc<br>|assertIdentifier<br>|charConcat<br>|conditionAssign<br>|constructorName <br>|deprecation<br>|emptyBlock<br>|fieldHiding<br>|finalBound<br>|finally<br>|indirectStatic<br>|intfNonInherited<br>|javadoc<br>|localHiding <br>|maskedCatchBlocks<br>|nls<br>|noEffectAssign<br>|pkgDefaultMethod<br>|semicolon<br> |specialParamHiding<br> |staticReceiver<br>|syntheticAccess<br>|tasks(<task1>|...|<taskN>)<br>|unqualifiedField<br>|unnecessaryElse<br>|uselessTypeCheck<br> |unsafe<br>|unusedArgument<br>|unusedImport<br>|unusedLocal<br>|unusedPrivate<br>|unusedThrown</blockquote> </td> <td valign=top>Set warning level.<br>e.g. <font color="#3366FF">-warn:unusedLocals,deprecation</font><br> <p> <pre> -warn:<warnings separated by ,> enable exactly the listed warnings -warn:+<warnings separated by ,> enable additional warnings -warn:-<warnings separated by ,> disable specific warnings </pre> <table> <tr> <th align=left valign=top>allDeprecation</th> <td valign=top>deprecation even inside deprecated code</td> </tr> <tr> <th align=left valign=top>allJavadoc</th> <td valign=top>invalid or missing javadoc</td> </tr> <tr> <th align=left valign=top>assertIdentifier</th> <td valign=top>occurrence of <i>assert</i> used as identifier</td> </tr> <tr> <th align=left valign=top>charConcat</th> <td valign=top>when a char array is used in a string concatenation without being converted explicitely to a string</td> </tr> <tr> <th align=left valign=top>conditionAssign</th> <td valign=top>possible accidental boolean assignment</td> </tr> <tr> <th align=left valign=top>constructorName</th> <td valign=top>method with constructor name</td> </tr> <tr> <th align=left valign=top>deprecation</th> <td valign=top>usage of deprecated type or member outside deprecated code</td> </tr> <tr> <th align=left valign=top>emptyBlock</th> <td valign=top>undocumented empty block</td> </tr> <tr> <th align=left valign=top>fieldHiding</th> <td valign=top>field hiding another variable</td> </tr> <tr> <th align=left valign=top>finalBound</th> <td valign=top>type parameter with final bound</td> </tr> <tr> <th align=left valign=top>finally</th> <td valign=top>finally block not completing normally</td> </tr> <tr> <th align=left valign=top>intfNonInherited</th> <td valign=top>interface non-inherited method compatibility</td> </tr> <tr> <th align=left valign=top>javadoc</th> <td valign=top>invalid javadoc</td> </tr> <tr> <th align=left valign=top>localHiding</th> <td valign=top>local variable hiding another variable</td> </tr> <tr> <th align=left valign=top>maskedCatchBlocks</th> <td valign=top>hidden catch block</td> </tr> <tr> <th align=left valign=top>nls</th> <td>non-nls string literals (lacking of tags //$NON-NLS-<n>)</td> </tr> <tr> <th align=left valign=top>noEffectAssign</th> <td valign=top>for assignment with no effect</td> </tr> <tr> <th align=left valign=top>pkgDefaultMethod</th> <td valign=top>attempt to override package-default method</td> </tr> <tr> <th align=left valign=top>semicolon</th> <td valign=top>unnecessary semicolon or empty statement</td> </tr> <tr> <th align=left valign=top>specialParamHiding</th> <td valign=top>constructor or setter parameter hiding another field</td> </tr> <tr> <th align=left valign=top>staticReceiver</th> <td valign=top>if a non static receiver is used to get a static field or call a static method</td> </tr> <tr> <th align=left valign=top>syntheticAccess</th> <td valign=top>when performing synthetic access for innerclass</td> </tr> <tr> <th align=left valign=top>tasks</th> <td valign=top>enable support for tasks tags in source code</td> </tr> <tr> <th align=left valign=top>unqualifiedField</th> <td valign=top>unqualified reference to field</td> </tr> <tr> <th align=left valign=top>unsafe</th> <td valign=top>unsafe type operation</td> </tr> <tr> <th align=left valign=top>unusedArgument</th> <td valign=top>unused method argument</td> </tr> <tr> <th align=left valign=top>unusedImport</th> <td valign=top>When enabled, the compiler will issue an error or a warning for unused import reference </td> </tr> <tr> <th align=left valign=top>unusedLocal</th> <td valign=top>unused local variable</td> </tr> <tr> <th align=left valign=top>unusedPrivate</th> <td valign=top>unused private member declaration</td> </tr> <tr> <th align=left valign=top>unusedThrown</th> <td valign=top>unused declared thrown exception</td> </tr> <tr> <th align=left valign=top>unnecessaryElse</th> <td valign=top>unnecessary else clause</td> </tr> <tr> <th align=left valign=top>uselessTypeCheck</th> <td valign=top>unnecessary cast/instanceof operation</td> </tr> </table> </td> </tr> <tr> <td valign=top>-nowarn</td> <td>No warning (equivalent to <font color="#3366FF">-warn:none</font>)</td> </tr> <tr> <td valign=top>-deprecation</td> <td>Equivalent to <font color="#3366FF">-warn:deprecation</font>.</td> </tr> <tr> <th colspan="2">Debug options</th> </tr> <tr> <td valign=top>-g[:none|:lines,vars,source] </td> <td>Set the debug attributes level<br> <table> <tr> <th align=left>-g</th> <td>All debug info (equivalent to <font color="#3366FF">-g:lines,vars,source</font>) </td> </tr> <th align=left>-g:none</th> <td>No debug info</td> </tr> <tr> <th align=left>-g:[lines,vars,source]</th> <td>Selective debug info</td> </tr> </table> </tr> <tr> <td valign=top>-preserveAllLocals</td> <td>Explicitly request the compiler to preserve all local variables (for debug purpose). If omitted, the compiler will removed unused locals.</td> </tr> <tr> <th colspan="2">Advanced options</th> </tr> <tr> <td>@<file></td> <td valign=top>Read command-line arguments from file</td> </tr> <tr> <td>-maxProblems <n></td> <td valign=top>Max number of problems per compilation unit (100 by default)</td> </tr> <tr> <td valign=top>-log <filename></td> <td>Specify a log file in which all output from the compiler will be dumped. This is really useful if you want to debug the batch compiler or get a file which contains all errors and warnings from a batch build.</td> </tr> <tr> <td valign=top>-proceedOnError</td> <td>Keep compiling when error, dumping class files with problem methods or problem types. This is recommanded only if you want to be able to run your application even if you have remaining errors.</td> </tr> <tr> <td valign=top>-verbose</td> <td>Print accessed/processed compilation units in the console or the log file if specified.</td> </tr> <tr> <td valign=top>-referenceInfo</td> <td>Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.</td> </tr> <tr> <td valign=top>-progress</td> <td>Show progress (only in -log mode)</td> </tr> <tr> <td valign=top>-time </td> <td>Display speed information</td> </tr> <tr> <td valign=top>-noExit</td> <td>Do not call <font color="#3366FF">System.exit(n)</font> at end of compilation (<font color="#3366FF">n=0</font> if no error)</td> </tr> <tr> <td valign=top>-repeat <n> </td> <td>Repeat compilation process <font color="#3366FF"><n></font> times (perf analysis).</td> </tr> <tr> <td valign=top>-inlineJSR</td> <td>Inline JSR bytecode (implicit if target >= 1.5)</td> </tr> <tr> <td valign=top>-enableJavadoc</td> <td>Consider references inside javadoc</td> </tr> <tr> <th colspan="2">Helping options</th> </tr> <tr> <td>-? -help</td> <td valign=top>Display the help message</td> </tr> <tr> <td valign=top>-v -version</td> <td>Display the build number of the compiler. This is very useful to report a bug.</td> </tr> <tr> <td valign=top>-showversion</td> <td>Display the build number of the compiler and continue. This is very useful to report a bug.</td> </tr> </table> </blockquote> </td> </tr> <tr> <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> <td WIDTH="98%"><b>Examples</b> <blockquote> <table> <td valign=top><font color="#3366FF">d:\temp -classpath rt.jar -time -g -d d:/tmp</font> </td> <td valign=top>It compiles all source files in d:\temp and its subfolders. The classpath is simply rt.jar. It generates all debug attributes and all generated .class files are dumped in d:\tmp. The speed of the compiler will be displayed once the batch process is completed.</td> </tr> <tr> <td valign=top><font color="#3366FF">d:\temp\Test.java -classpath d:\temp;rt.jar -g:none</font> </td> <td valign=top>It compiles only Test.java and it will retrieve any dependant files from d:\temp. The classpath is rt.jar and d:\temp, which means that all necessary classes are searched first in d:\temp and then in rt.jar. It generates no debug attributes and all generated .class files are dumped in d:\tmp.</td> </table> </blockquote> </td> </tr> </table> </body> </html>
| help@eclipse.org | ViewVC Help |
| Powered by ViewVC 1.0.3 |
