jdt-core-home/howto/batch compile/batchCompile.html
Parent Directory
|
Revision Log
Revision 1.3 - (view) (download) (as text)
| 1 : | pmulet | 1.1 | <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> |
| 2 : | <html> | ||
| 3 : | <head> | ||
| 4 : | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
| 5 : | <meta name="GENERATOR" content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]"> | ||
| 6 : | <title>How to: Run batch compiler</title> | ||
| 7 : | <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css"> | ||
| 8 : | </head> | ||
| 9 : | <body text="#000000" bgcolor="#FFFFFF"> | ||
| 10 : | | ||
| 11 : | <table BORDER=0 CELLSPACING=5 CELLPADDING=2 WIDTH="100%" > | ||
| 12 : | <tr> | ||
| 13 : | <td ALIGN=LEFT VALIGN=TOP COLSPAN="2" BGCOLOR="#0080C0"><b><font color="#FFFFFF">JDT | ||
| 14 : | Core / HowTo: Run the Batch Compiler </font></b></td> | ||
| 15 : | </tr> | ||
| 16 : | |||
| 17 : | <tr> | ||
| 18 : | <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> | ||
| 19 : | |||
| 20 : | <td WIDTH="98%"><b>Finding the batch compiler</b> | ||
| 21 : | <br>The batch compiler class is located in the internal classes of the | ||
| 22 : | JDT/Core plugin. So it is in the <i>jdtcore.jar</i> file in the directory | ||
| 23 : | <i>plugins/org.eclipse.jdt.core</i>. | ||
| 24 : | The name of the class is <i>org.eclipse.jdt.internal.compiler.batch.Main</i>. </td> | ||
| 25 : | </tr> | ||
| 26 : | |||
| 27 : | <tr> | ||
| 28 : | <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> | ||
| 29 : | |||
| 30 : | <td WIDTH="98%"><b>Running the batch compiler</b> | ||
| 31 : | <ul> | ||
| 32 : | <li> | ||
| 33 : | Using the main method.</li> | ||
| 34 : | |||
| 35 : | <blockquote>Using the main method. The Main class has a main method. This | ||
| 36 : | is the classical way to invoke the batch compiler on a command-line. | ||
| 37 : | <ul> | ||
| 38 : | <li> | ||
| 39 : | For example on a command-line:</li> | ||
| 40 : | |||
| 41 : | <br><font color="#3366FF">java -classpath jdtcore.jar org.eclipse.jdt.internal.compiler.batch.Main | ||
| 42 : | -classpath rt.jar A.java</font> | ||
| 43 : | <li> | ||
| 44 : | For example in a java source:</li> | ||
| 45 : | |||
| 46 : | <br><font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.main(new | ||
| 47 : | String[] {"-classpath", "rt.jar", "A.java"});</font></ul> | ||
| 48 : | </blockquote> | ||
| 49 : | |||
| 50 : | <li> | ||
| 51 : | Using the static compile(String) method.</li> | ||
| 52 : | |||
| 53 : | <blockquote>The compile(String) method is a convenient method to invoke | ||
| 54 : | the batch compiler in a java application. | ||
| 55 : | <br>Instead of: | ||
| 56 : | <ul> | ||
| 57 : | <li> | ||
| 58 : | <font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.main(new | ||
| 59 : | String[] {"-classpath", "rt.jar", "A.java"});</font></li> | ||
| 60 : | |||
| 61 : | <li> | ||
| 62 : | you can simply write: <font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.compile("-classpath | ||
| 63 : | rt.jar A.java");</font></li> | ||
| 64 : | </ul> | ||
| 65 : | </blockquote> | ||
| 66 : | </ul> | ||
| 67 : | </td> | ||
| 68 : | </tr> | ||
| 69 : | |||
| 70 : | <tr> | ||
| 71 : | <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> | ||
| 72 : | |||
| 73 : | <td WIDTH="98%"><b>Which options are available?</b> | ||
| 74 : | <p> | ||
| 75 : | With the orange background, these are suggested options. | ||
| 76 : | </p> | ||
| 77 : | <blockquote> | ||
| 78 : | <table BORDER CELLSPACING=2 CELLPADDING=2 COLS=2 WIDTH="100%" > | ||
| 79 : | <tr> | ||
| 80 : | <th>Name</th> | ||
| 81 : | <th>Usage</th> | ||
| 82 : | </tr> | ||
| 83 : | <tr> | ||
| 84 : | <td>-help</td> | ||
| 85 : | <td valign=top>Display the help message</td> | ||
| 86 : | </tr> | ||
| 87 : | <tr> | ||
| 88 : | <td valign=top>-version</td> | ||
| 89 : | <td>Display the build number of the compiler. This is very useful to report a bug.</td> | ||
| 90 : | </tr> | ||
| 91 : | <tr> | ||
| 92 : | oliviert | 1.2 | <td valign=top bgcolor="#FFCCAA">-bootclasspath <dir 1>;<dir 2>;...;<dir P></td> |
| 93 : | <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 | ||
| 94 : | VM are used.</td> | ||
| 95 : | </tr> | ||
| 96 : | <tr> | ||
| 97 : | <td valign=top bgcolor="#FFCCAA">-classpath <dir 1>;<dir 2>;...;<dir P></td> | ||
| 98 : | <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". | ||
| 99 : | </td> | ||
| 100 : | pmulet | 1.1 | </tr> |
| 101 : | <tr> | ||
| 102 : | <td valign=top bgcolor="#FFCCAA">-d <dir 1>|none</td> | ||
| 103 : | <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> | ||
| 104 : | If you don't want to generate .class files, use <font color="#3366FF">-d none</font>.</td> | ||
| 105 : | </tr> | ||
| 106 : | <tr> | ||
| 107 : | <td valign=top>-target 1.1|1.2</td> | ||
| 108 : | <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.1</font></td> | ||
| 109 : | </tr> | ||
| 110 : | <tr> | ||
| 111 : | <td valign=top>-1.3</td> | ||
| 112 : | <td>Set compliance level to <font color="#3366FF">1.3</font> (default)</td> | ||
| 113 : | </tr> | ||
| 114 : | <tr> | ||
| 115 : | <td valign=top>-1.4</td> | ||
| 116 : | <td>Set compliance level to <font color="#3366FF">1.4</font>.</td> | ||
| 117 : | </tr> | ||
| 118 : | <tr> | ||
| 119 : | <td valign=top>-source 1.3|1.4</td> | ||
| 120 : | <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. | ||
| 121 : | In <font color="#3366FF">1.4</font>, <font color="#3366FF"><I>assert</I></font> is treated as a keyword.</td> | ||
| 122 : | </tr> | ||
| 123 : | <tr> | ||
| 124 : | oliviert | 1.3 | <td valign=top>-warn: <blockquote>constructorName<br>|packageDefaultMethod<br>|deprecation<br>|maskedCatchBlocks<br>|unusedLocals<br>|unusedArguments<br>|unusedImports<br>|syntheticAccess<br>|assertIdentifier<br>|allDeprecation<br>|nls<br>|staticReceiver<br>|noEffectAssign<br>|noImplicitStringConversion<br>|tasks(<task1>|...|<taskN>)</blockquote> |
| 125 : | pmulet | 1.1 | </td> |
| 126 : | oliviert | 1.3 | <td valign=top>Set warning level.<br>e.g. <font color="#3366FF">-warn:unusedLocals,deprecation</font><br> |
| 127 : | pmulet | 1.1 | <table> |
| 128 : | <tr> | ||
| 129 : | oliviert | 1.3 | <th align=left valign=top>constructorName</th> |
| 130 : | <td valign=top>warn method with constructor name</td> | ||
| 131 : | pmulet | 1.1 | </tr> |
| 132 : | <tr> | ||
| 133 : | oliviert | 1.3 | <th align=left valign=top>packageDefaultMethod</th> |
| 134 : | <td valign=top>warn attempt to override package-default method</td> | ||
| 135 : | pmulet | 1.1 | </tr> |
| 136 : | <tr> | ||
| 137 : | oliviert | 1.3 | <th align=left valign=top>deprecation</th> |
| 138 : | <td valign=top>warn usage of deprecated type or member</td> | ||
| 139 : | pmulet | 1.1 | </tr> |
| 140 : | <tr> | ||
| 141 : | oliviert | 1.3 | <th align=left valign=top>maskedCatchBlocks</th> |
| 142 : | <td valign=top>warn hidden catch block</td> | ||
| 143 : | pmulet | 1.1 | </tr> |
| 144 : | <tr> | ||
| 145 : | oliviert | 1.3 | <th align=left valign=top>unusedLocals</th> |
| 146 : | <td valign=top>warn unused local variable</td> | ||
| 147 : | pmulet | 1.1 | </tr> |
| 148 : | <tr> | ||
| 149 : | oliviert | 1.3 | <th align=left valign=top>unusedArguments</th> |
| 150 : | <td valign=top>warn unused method argument</td> | ||
| 151 : | pmulet | 1.1 | </tr> |
| 152 : | <tr> | ||
| 153 : | oliviert | 1.3 | <th align=left valign=top>unusedImports</th> |
| 154 : | <td valign=top>When enabled, the compiler will issue an error or a warning for unused import reference | ||
| 155 : | pmulet | 1.1 | </td> |
| 156 : | </tr> | ||
| 157 : | <tr> | ||
| 158 : | oliviert | 1.3 | <th align=left valign=top>syntheticAccess</th> |
| 159 : | <td valign=top>warn when performing synthetic access for innerclass</td> | ||
| 160 : | pmulet | 1.1 | </tr> |
| 161 : | <tr> | ||
| 162 : | oliviert | 1.3 | <th align=left valign=top>assertIdentifier</th> |
| 163 : | <td valign=top>warn occurrence of <i>assert</i> used as identifier</td> | ||
| 164 : | </tr> | ||
| 165 : | <tr> | ||
| 166 : | <th align=left valign=top>allDeprecation</th> | ||
| 167 : | <td valign=top>warn for deprecation even in deprecated code</td> | ||
| 168 : | </tr> | ||
| 169 : | <tr> | ||
| 170 : | <th align=left valign=top>nls</th> | ||
| 171 : | <td>warn non-nls string literals (lacking of tags //$NON-NLS-<n>)</td> | ||
| 172 : | </tr> | ||
| 173 : | <tr> | ||
| 174 : | <th align=left valign=top>staticReceiver</th> | ||
| 175 : | <td valign=top>warn if a non static receiver is used to get a static field or call a static method</td> | ||
| 176 : | </tr> | ||
| 177 : | <tr> | ||
| 178 : | <th align=left valign=top>noEffectAssign</th> | ||
| 179 : | <td valign=top>warn for assignment with no effect</td> | ||
| 180 : | </tr> | ||
| 181 : | <tr> | ||
| 182 : | <th align=left valign=top>noImplicitStringConversion</th> | ||
| 183 : | <td valign=top>warn when a char array is used in a string concatenation without being converted explicitely to | ||
| 184 : | a string</td> | ||
| 185 : | </tr> | ||
| 186 : | <tr> | ||
| 187 : | <th align=left valign=top>tasks</th> | ||
| 188 : | <td valign=top>enable support for tasks tags in source code</td> | ||
| 189 : | pmulet | 1.1 | </tr> |
| 190 : | </table> | ||
| 191 : | </td> | ||
| 192 : | </tr> | ||
| 193 : | <tr> | ||
| 194 : | <td valign=top>-nowarn</td> | ||
| 195 : | <td>No warning (equivalent to <font color="#3366FF">-warn:none</font>)</td> | ||
| 196 : | </tr> | ||
| 197 : | <tr> | ||
| 198 : | <td valign=top>-deprecation</td> | ||
| 199 : | <td>Equivalent to <font color="#3366FF">-warn:deprecation</font>.</td> | ||
| 200 : | </tr> | ||
| 201 : | <tr> | ||
| 202 : | <td valign=top>-g[:none|:lines,vars,source] | ||
| 203 : | </td> | ||
| 204 : | <td>Set the debug attributes level<br> | ||
| 205 : | <table> | ||
| 206 : | <tr> | ||
| 207 : | <th align=left>-g</th> | ||
| 208 : | <td>All debug info (equivalent to <font color="#3366FF">-g:lines,vars,source</font>) | ||
| 209 : | </td> | ||
| 210 : | </tr> | ||
| 211 : | <th align=left>-g:none</th> | ||
| 212 : | <td>No debug info</td> | ||
| 213 : | </tr> | ||
| 214 : | <tr> | ||
| 215 : | <th align=left>-g:[lines,vars,source]</th> | ||
| 216 : | <td>Selective debug info</td> | ||
| 217 : | </tr> | ||
| 218 : | </table> | ||
| 219 : | </tr> | ||
| 220 : | <tr> | ||
| 221 : | <td valign=top>-preserveAllLocals</td> | ||
| 222 : | <td>Explicitly request the compiler to preserve all local variables (for debug purpose). If omitted, the compiler will removed unused locals.</td> | ||
| 223 : | </tr> | ||
| 224 : | <tr> | ||
| 225 : | <td valign=top>-noImportError</td> | ||
| 226 : | <td>The compiler won't report an error for unresolved imports. A warning is issued instead.</td> | ||
| 227 : | </tr> | ||
| 228 : | <tr> | ||
| 229 : | <td valign=top>-encoding <encoding name></td> | ||
| 230 : | <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> | ||
| 231 : | </tr> | ||
| 232 : | <tr> | ||
| 233 : | <td valign=top>-log <filename></td> | ||
| 234 : | <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 | ||
| 235 : | compiler or get a file which contains all errors and warnings from a batch build.</td> | ||
| 236 : | </tr> | ||
| 237 : | <tr> | ||
| 238 : | <td valign=top>-proceedOnError</td> | ||
| 239 : | <td>Keep compiling when error, dumping class files with problem methods or problem types. This is recommanded only if you want | ||
| 240 : | to be able to run your application even if you have remaining errors.</td> | ||
| 241 : | </tr> | ||
| 242 : | <tr> | ||
| 243 : | <td valign=top>-verbose</td> | ||
| 244 : | <td>Print accessed/processed compilation units in the console or the log file if specified.</td> | ||
| 245 : | </tr> | ||
| 246 : | <tr> | ||
| 247 : | <td valign=top>-referenceInfo</td> | ||
| 248 : | <td>Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.</td> | ||
| 249 : | </tr> | ||
| 250 : | <tr> | ||
| 251 : | <td valign=top>-progress</td> | ||
| 252 : | <td>Show progress (only in -log mode)</td> | ||
| 253 : | </tr> | ||
| 254 : | <tr> | ||
| 255 : | <td valign=top>-time | ||
| 256 : | </td> | ||
| 257 : | <td>Display speed information</td> | ||
| 258 : | </tr> | ||
| 259 : | <tr> | ||
| 260 : | <td valign=top>-noExit</td> | ||
| 261 : | <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> | ||
| 262 : | </tr> | ||
| 263 : | <tr> | ||
| 264 : | <td valign=top>-repeat <n> | ||
| 265 : | </td> | ||
| 266 : | <td>Repeat compilation process <font color="#3366FF"><n></font> times (perf analysis).</td> | ||
| 267 : | </tr> | ||
| 268 : | </table> | ||
| 269 : | </blockquote> | ||
| 270 : | </td> | ||
| 271 : | </tr> | ||
| 272 : | <tr> | ||
| 273 : | <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td> | ||
| 274 : | |||
| 275 : | <td WIDTH="98%"><b>Examples</b> | ||
| 276 : | <blockquote> | ||
| 277 : | <table> | ||
| 278 : | <td valign=top><font color="#3366FF">d:\temp -classpath rt.jar -time -g -d d:/tmp</font> | ||
| 279 : | </td> | ||
| 280 : | <td valign=top>It compiles all source files in d:\temp and its subfolders. The classpath is simply rt.jar. It generates all debug | ||
| 281 : | attributes and all generated .class files are dumped in d:\tmp. The speed of the compiler will be displayed once the batch process | ||
| 282 : | is completed.</td> | ||
| 283 : | </tr> | ||
| 284 : | <tr> | ||
| 285 : | <td valign=top><font color="#3366FF">d:\temp\Test.java -classpath d:\temp;rt.jar -g:none</font> | ||
| 286 : | </td> | ||
| 287 : | <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 | ||
| 288 : | 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> | ||
| 289 : | </table> | ||
| 290 : | </blockquote> | ||
| 291 : | </td> | ||
| 292 : | </tr> | ||
| 293 : | |||
| 294 : | </table> | ||
| 295 : | |||
| 296 : | |||
| 297 : | |||
| 298 : | </body> | ||
| 299 : | </html> |
| help@eclipse.org | ViewVC Help |
| Powered by ViewVC 1.0.3 |
