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

Parent Directory Parent Directory | Revision Log Revision Log


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