jdt-core-home/howto/batch compile/batchCompile.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (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 :     &nbsp;
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&nbsp;</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>.&nbsp;</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>&nbsp;
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 : oliviert 1.4 <th colspan="2">Classpath options</th>
85 : pmulet 1.1 </tr>
86 :     <tr>
87 : oliviert 1.2 <td valign=top bgcolor="#FFCCAA">-bootclasspath &lt;dir 1&gt;;&lt;dir 2&gt;;...;&lt;dir P&gt;</td>
88 :     <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
89 : oliviert 1.4 VM are used. Entries are separated by the platform path separator.</td>
90 : oliviert 1.2 </tr>
91 :     <tr>
92 : oliviert 1.4 <td valign=top bgcolor="#FFCCAA">-cp -classpath &lt;dir 1&gt;;&lt;dir 2&gt;;...;&lt;dir P&gt;</td>
93 : oliviert 1.2 <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".
94 : oliviert 1.4 Entries are separated by the platform path separator.
95 : oliviert 1.2 </td>
96 : pmulet 1.1 </tr>
97 :     <tr>
98 :     <td valign=top bgcolor="#FFCCAA">-d &lt;dir 1&gt;|none</td>
99 :     <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>
100 :     If you don't want to generate .class files, use <font color="#3366FF">-d none</font>.</td>
101 :     </tr>
102 :     <tr>
103 : oliviert 1.4 <td valign=top>-encoding &lt;encoding name&gt;</td>
104 :     <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 &lt;encoding name&gt;]</font>).</td>
105 :     </tr>
106 :     <tr>
107 :     <th colspan="2">Compliance options</th>
108 :     </tr>
109 :     <tr>
110 :     <td valign=top>-target 1.1|1.2|1.3|1.4|1.5</td>
111 :     <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>
112 : pmulet 1.1 </tr>
113 :     <tr>
114 :     <td valign=top>-1.3</td>
115 : oliviert 1.4 <td>Set compliance level to <font color="#3366FF">1.3</font>. Implicit -source 1.3 -target 1.1.</td>
116 : pmulet 1.1 </tr>
117 :     <tr>
118 :     <td valign=top>-1.4</td>
119 : oliviert 1.4 <td>Set compliance level to <font color="#3366FF">1.4</font> (default). Implicit -source 1.3 -target 1.2.</td>
120 :     </tr>
121 :     <tr>
122 :     <td valign=top>-1.5</td>
123 :     <td>Set compliance level to <font color="#3366FF">1.5</font>. Implicit -source 1.5 -target 1.5.</td>
124 : pmulet 1.1 </tr>
125 :     <tr>
126 : oliviert 1.4 <td valign=top>-source 1.3|1.4|1.5</td>
127 : pmulet 1.1 <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.
128 :     In <font color="#3366FF">1.4</font>, <font color="#3366FF"><I>assert</I></font> is treated as a keyword.</td>
129 :     </tr>
130 :     <tr>
131 : oliviert 1.4 <th colspan="2">Warning options</th>
132 :     </tr>
133 :     <tr>
134 : oliviert 1.5 <td valign=top>-warn:<blockquote>&nbsp;allDeprecation<br>|allJavadoc<br>|<font color="#FF0000">assertIdentifier</font><br>|<font color="#FF0000">charConcat</font><br>|conditionAssign<br>|<font color="#FF0000">constructorName</font>
135 :     <br>|<font color="#FF0000">deprecation</font><br>|emptyBlock<br>|fieldHiding<br>|finalBound<br>|<font color="#FF0000">finally</font><br>|indirectStatic<br>|<font color="#FF0000">intfNonInherited</font><br>|javadoc<br>|localHiding
136 :     <br>|<font color="#FF0000">maskedCatchBlocks</font><br>|nls<br>|<font color="#FF0000">noEffectAssign</font><br>|<font color="#FF0000">pkgDefaultMethod</font><br>|<font color="#FF0000">serial</font><br>|semicolon<br>
137 : oliviert 1.4 |specialParamHiding<br>
138 : oliviert 1.5 |<font color="#FF0000">staticReceiver</font><br>|syntheticAccess<br>|tasks(&lt;task1&gt;|...|&lt;taskN&gt;)<br>|unqualifiedField<br>|unnecessaryElse<br>|uselessTypeCheck<br>
139 :     |<font color="#FF0000">unsafe</font><br>|unusedArgument<br>|<font color="#FF0000">unusedImport</font><br>|unusedLocal<br>|unusedPrivate<br>|unusedThrown</blockquote>
140 : pmulet 1.1 </td>
141 : oliviert 1.3 <td valign=top>Set warning level.<br>e.g. <font color="#3366FF">-warn:unusedLocals,deprecation</font><br>
142 : oliviert 1.5 <p>In <font color="#FF0000">red</font> are the default settings.</p>
143 : oliviert 1.4 <p>
144 :     <pre>
145 :     -warn:<warnings separated by ,> enable exactly the listed warnings
146 :     -warn:+<warnings separated by ,> enable additional warnings
147 :     -warn:-<warnings separated by ,> disable specific warnings
148 :     </pre>
149 : pmulet 1.1 <table>
150 :     <tr>
151 : oliviert 1.4 <th align=left valign=top>allDeprecation</th>
152 :     <td valign=top>deprecation even inside deprecated code</td>
153 :     </tr>
154 :     <tr>
155 :     <th align=left valign=top>allJavadoc</th>
156 :     <td valign=top>invalid or missing javadoc</td>
157 :     </tr>
158 :     <tr>
159 :     <th align=left valign=top>assertIdentifier</th>
160 :     <td valign=top>occurrence of <i>assert</i> used as identifier</td>
161 :     </tr>
162 :     <tr>
163 :     <th align=left valign=top>charConcat</th>
164 :     <td valign=top>when a char array is used in a string concatenation without being converted explicitely to
165 :     a string</td>
166 :     </tr>
167 :     <tr>
168 :     <th align=left valign=top>conditionAssign</th>
169 :     <td valign=top>possible accidental boolean assignment</td>
170 :     </tr>
171 :     <tr>
172 : oliviert 1.3 <th align=left valign=top>constructorName</th>
173 : oliviert 1.4 <td valign=top>method with constructor name</td>
174 : pmulet 1.1 </tr>
175 :     <tr>
176 : oliviert 1.4 <th align=left valign=top>deprecation</th>
177 :     <td valign=top>usage of deprecated type or member outside deprecated code</td>
178 : pmulet 1.1 </tr>
179 :     <tr>
180 : oliviert 1.4 <th align=left valign=top>emptyBlock</th>
181 :     <td valign=top>undocumented empty block</td>
182 : pmulet 1.1 </tr>
183 :     <tr>
184 : oliviert 1.4 <th align=left valign=top>fieldHiding</th>
185 :     <td valign=top>field hiding another variable</td>
186 : pmulet 1.1 </tr>
187 :     <tr>
188 : oliviert 1.4 <th align=left valign=top>finalBound</th>
189 :     <td valign=top>type parameter with final bound</td>
190 : pmulet 1.1 </tr>
191 :     <tr>
192 : oliviert 1.4 <th align=left valign=top>finally</th>
193 :     <td valign=top>finally block not completing normally</td>
194 : pmulet 1.1 </tr>
195 :     <tr>
196 : oliviert 1.4 <th align=left valign=top>intfNonInherited</th>
197 :     <td valign=top>interface non-inherited method compatibility</td>
198 : pmulet 1.1 </tr>
199 :     <tr>
200 : oliviert 1.4 <th align=left valign=top>javadoc</th>
201 :     <td valign=top>invalid javadoc</td>
202 : pmulet 1.1 </tr>
203 :     <tr>
204 : oliviert 1.4 <th align=left valign=top>localHiding</th>
205 :     <td valign=top>local variable hiding another variable</td>
206 : oliviert 1.3 </tr>
207 :     <tr>
208 : oliviert 1.4 <th align=left valign=top>maskedCatchBlocks</th>
209 :     <td valign=top>hidden catch block</td>
210 : oliviert 1.3 </tr>
211 :     <tr>
212 :     <th align=left valign=top>nls</th>
213 : oliviert 1.4 <td>non-nls string literals (lacking of tags //$NON-NLS-&lt;n&gt;)</td>
214 :     </tr>
215 :     <tr>
216 :     <th align=left valign=top>noEffectAssign</th>
217 :     <td valign=top>for assignment with no effect</td>
218 : oliviert 1.3 </tr>
219 :     <tr>
220 : oliviert 1.4 <th align=left valign=top>pkgDefaultMethod</th>
221 :     <td valign=top>attempt to override package-default method</td>
222 : oliviert 1.5 </tr>
223 :     <tr>
224 :     <th align=left valign=top>serial</th>
225 :     <td valign=top>missing serialVersionUID</td>
226 : oliviert 1.4 </tr>
227 :     <tr>
228 :     <th align=left valign=top>semicolon</th>
229 :     <td valign=top>unnecessary semicolon or empty statement</td>
230 :     </tr>
231 :     <tr>
232 :     <th align=left valign=top>specialParamHiding</th>
233 :     <td valign=top>constructor or setter parameter hiding another field</td>
234 : oliviert 1.3 </tr>
235 :     <tr>
236 : oliviert 1.4 <th align=left valign=top>staticReceiver</th>
237 :     <td valign=top>if a non static receiver is used to get a static field or call a static method</td>
238 : oliviert 1.3 </tr>
239 :     <tr>
240 : oliviert 1.4 <th align=left valign=top>syntheticAccess</th>
241 :     <td valign=top>when performing synthetic access for innerclass</td>
242 : oliviert 1.3 </tr>
243 :     <tr>
244 :     <th align=left valign=top>tasks</th>
245 :     <td valign=top>enable support for tasks tags in source code</td>
246 : pmulet 1.1 </tr>
247 : oliviert 1.4 <tr>
248 :     <th align=left valign=top>unqualifiedField</th>
249 :     <td valign=top>unqualified reference to field</td>
250 :     </tr>
251 :     <tr>
252 :     <th align=left valign=top>unsafe</th>
253 :     <td valign=top>unsafe type operation</td>
254 :     </tr>
255 :     <tr>
256 :     <th align=left valign=top>unusedArgument</th>
257 :     <td valign=top>unused method argument</td>
258 :     </tr>
259 :     <tr>
260 :     <th align=left valign=top>unusedImport</th>
261 :     <td valign=top>When enabled, the compiler will issue an error or a warning for unused import reference
262 :     </td>
263 :     </tr>
264 :     <tr>
265 :     <th align=left valign=top>unusedLocal</th>
266 :     <td valign=top>unused local variable</td>
267 :     </tr>
268 :     <tr>
269 :     <th align=left valign=top>unusedPrivate</th>
270 :     <td valign=top>unused private member declaration</td>
271 :     </tr>
272 :     <tr>
273 :     <th align=left valign=top>unusedThrown</th>
274 :     <td valign=top>unused declared thrown exception</td>
275 :     </tr>
276 :     <tr>
277 :     <th align=left valign=top>unnecessaryElse</th>
278 :     <td valign=top>unnecessary else clause</td>
279 :     </tr>
280 :     <tr>
281 :     <th align=left valign=top>uselessTypeCheck</th>
282 :     <td valign=top>unnecessary cast/instanceof operation</td>
283 :     </tr>
284 : pmulet 1.1 </table>
285 :     </td>
286 :     </tr>
287 :     <tr>
288 :     <td valign=top>-nowarn</td>
289 :     <td>No warning (equivalent to <font color="#3366FF">-warn:none</font>)</td>
290 :     </tr>
291 :     <tr>
292 :     <td valign=top>-deprecation</td>
293 :     <td>Equivalent to <font color="#3366FF">-warn:deprecation</font>.</td>
294 :     </tr>
295 :     <tr>
296 : oliviert 1.4 <th colspan="2">Debug options</th>
297 :     </tr>
298 :     <tr>
299 : pmulet 1.1 <td valign=top>-g[:none|:lines,vars,source]
300 :     </td>
301 :     <td>Set the debug attributes level<br>
302 :     <table>
303 :     <tr>
304 :     <th align=left>-g</th>
305 :     <td>All debug info (equivalent to <font color="#3366FF">-g:lines,vars,source</font>)
306 :     </td>
307 :     </tr>
308 :     <th align=left>-g:none</th>
309 :     <td>No debug info</td>
310 :     </tr>
311 :     <tr>
312 :     <th align=left>-g:[lines,vars,source]</th>
313 :     <td>Selective debug info</td>
314 :     </tr>
315 :     </table>
316 :     </tr>
317 :     <tr>
318 :     <td valign=top>-preserveAllLocals</td>
319 :     <td>Explicitly request the compiler to preserve all local variables (for debug purpose). If omitted, the compiler will removed unused locals.</td>
320 :     </tr>
321 :     <tr>
322 : oliviert 1.4 <th colspan="2">Advanced options</th>
323 :     </tr>
324 :     <tr>
325 :     <td>@&lt;file&gt;</td>
326 :     <td valign=top>Read command-line arguments from file</td>
327 : pmulet 1.1 </tr>
328 :     <tr>
329 : oliviert 1.4 <td>-maxProblems&nbsp;&lt;n&gt;</td>
330 :     <td valign=top>Max number of problems per compilation unit (100 by default)</td>
331 : pmulet 1.1 </tr>
332 :     <tr>
333 :     <td valign=top>-log &lt;filename&gt;</td>
334 :     <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
335 :     compiler or get a file which contains all errors and warnings from a batch build.</td>
336 :     </tr>
337 :     <tr>
338 :     <td valign=top>-proceedOnError</td>
339 :     <td>Keep compiling when error, dumping class files with problem methods or problem types. This is recommanded only if you want
340 :     to be able to run your application even if you have remaining errors.</td>
341 :     </tr>
342 :     <tr>
343 :     <td valign=top>-verbose</td>
344 :     <td>Print accessed/processed compilation units in the console or the log file if specified.</td>
345 :     </tr>
346 :     <tr>
347 :     <td valign=top>-referenceInfo</td>
348 :     <td>Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.</td>
349 :     </tr>
350 :     <tr>
351 :     <td valign=top>-progress</td>
352 :     <td>Show progress (only in -log mode)</td>
353 :     </tr>
354 :     <tr>
355 :     <td valign=top>-time
356 :     </td>
357 :     <td>Display speed information</td>
358 :     </tr>
359 :     <tr>
360 :     <td valign=top>-noExit</td>
361 :     <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>
362 :     </tr>
363 :     <tr>
364 :     <td valign=top>-repeat &lt;n&gt;
365 :     </td>
366 :     <td>Repeat compilation process <font color="#3366FF">&lt;n&gt;</font> times (perf analysis).</td>
367 : oliviert 1.4 </tr>
368 :     <tr>
369 :     <td valign=top>-inlineJSR</td>
370 :     <td>Inline JSR bytecode (implicit if target >= 1.5)</td>
371 :     </tr>
372 :     <tr>
373 :     <td valign=top>-enableJavadoc</td>
374 :     <td>Consider references inside javadoc</td>
375 :     </tr>
376 :     <tr>
377 :     <th colspan="2">Helping options</th>
378 :     </tr>
379 :     <tr>
380 :     <td>-? -help</td>
381 :     <td valign=top>Display the help message</td>
382 :     </tr>
383 :     <tr>
384 :     <td valign=top>-v -version</td>
385 :     <td>Display the build number of the compiler. This is very useful to report a bug.</td>
386 :     </tr>
387 :     <tr>
388 :     <td valign=top>-showversion</td>
389 :     <td>Display the build number of the compiler and continue. This is very useful to report a bug.</td>
390 : pmulet 1.1 </tr>
391 :     </table>
392 :     </blockquote>
393 :     </td>
394 :     </tr>
395 :     <tr>
396 :     <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
397 :    
398 :     <td WIDTH="98%"><b>Examples</b>
399 :     <blockquote>
400 :     <table>
401 :     <td valign=top><font color="#3366FF">d:\temp -classpath rt.jar -time -g -d d:/tmp</font>
402 :     </td>
403 :     <td valign=top>It compiles all source files in d:\temp and its subfolders. The classpath is simply rt.jar. It generates all debug
404 :     attributes and all generated .class files are dumped in d:\tmp. The speed of the compiler will be displayed once the batch process
405 :     is completed.</td>
406 :     </tr>
407 :     <tr>
408 :     <td valign=top><font color="#3366FF">d:\temp\Test.java -classpath d:\temp;rt.jar -g:none</font>
409 :     </td>
410 :     <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
411 :     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>
412 :     </table>
413 :     </blockquote>
414 :     </td>
415 :     </tr>
416 :    
417 :     </table>
418 :    
419 :    
420 :    
421 :     </body>
422 :     </html>