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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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 :     <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 &lt;dir 1&gt;;&lt;dir 2&gt;;...;&lt;dir P&gt;</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 &lt;dir 1&gt;;&lt;dir 2&gt;;...;&lt;dir P&gt;</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 &lt;dir 1&gt;|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 :     <td valign=top>-warn: <blockquote>constructorName<br>|packageDefaultMethod<br>|deprecation<br>|maskedCatchBlocks<br>|unusedLocals<br>|unusedArguments<br>|unusedImports<br>|syntheticAccess<br>|assertIdentifier</blockquote>
125 :     </td>
126 :     <td>Set warning level.<br>e.g. <font color="#3366FF">-warn:unusedLocals,deprecation</font><br>
127 :     <table>
128 :     <tr>
129 :     <th align=left>constructorName</th>
130 :     <td>warn method with constructor name</td>
131 :     </tr>
132 :     <tr>
133 :     <th align=left>packageDefaultMethod</th>
134 :     <td>warn attempt to override package-default method</td>
135 :     </tr>
136 :     <tr>
137 :     <th align=left>deprecation</th>
138 :     <td>warn usage of deprecated type or member</td>
139 :     </tr>
140 :     <tr>
141 :     <th align=left>maskedCatchBlocks</th>
142 :     <td>warn hidden catch block</td>
143 :     </tr>
144 :     <tr>
145 :     <th align=left>unusedLocals</th>
146 :     <td>warn unused local variable</td>
147 :     </tr>
148 :     <tr>
149 :     <th align=left>unusedArguments</th>
150 :     <td>warn unused method argument</td>
151 :     </tr>
152 :     <tr>
153 :     <th align=left>unusedImports</th>
154 :     <td>When enabled, the compiler will issue an error or a warning for unused import reference
155 :     </td>
156 :     </tr>
157 :     <tr>
158 :     <th align=left>syntheticAccess</th>
159 :     <td>warn when performing synthetic access for innerclass</td>
160 :     </tr>
161 :     <tr>
162 :     <th align=left>assertIdentifier</th>
163 :     <td>warn occurrence of <i>assert</i> used as identifier</td>
164 :     </tr>
165 :     </table>
166 :     </td>
167 :     </tr>
168 :     <tr>
169 :     <td valign=top>-nowarn</td>
170 :     <td>No warning (equivalent to <font color="#3366FF">-warn:none</font>)</td>
171 :     </tr>
172 :     <tr>
173 :     <td valign=top>-deprecation</td>
174 :     <td>Equivalent to <font color="#3366FF">-warn:deprecation</font>.</td>
175 :     </tr>
176 :     <tr>
177 :     <td valign=top>-g[:none|:lines,vars,source]
178 :     </td>
179 :     <td>Set the debug attributes level<br>
180 :     <table>
181 :     <tr>
182 :     <th align=left>-g</th>
183 :     <td>All debug info (equivalent to <font color="#3366FF">-g:lines,vars,source</font>)
184 :     </td>
185 :     </tr>
186 :     <th align=left>-g:none</th>
187 :     <td>No debug info</td>
188 :     </tr>
189 :     <tr>
190 :     <th align=left>-g:[lines,vars,source]</th>
191 :     <td>Selective debug info</td>
192 :     </tr>
193 :     </table>
194 :     </tr>
195 :     <tr>
196 :     <td valign=top>-preserveAllLocals</td>
197 :     <td>Explicitly request the compiler to preserve all local variables (for debug purpose). If omitted, the compiler will removed unused locals.</td>
198 :     </tr>
199 :     <tr>
200 :     <td valign=top>-noImportError</td>
201 :     <td>The compiler won't report an error for unresolved imports. A warning is issued instead.</td>
202 :     </tr>
203 :     <tr>
204 :     <td valign=top>-encoding &lt;encoding name&gt;</td>
205 :     <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>
206 :     </tr>
207 :     <tr>
208 :     <td valign=top>-log &lt;filename&gt;</td>
209 :     <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
210 :     compiler or get a file which contains all errors and warnings from a batch build.</td>
211 :     </tr>
212 :     <tr>
213 :     <td valign=top>-proceedOnError</td>
214 :     <td>Keep compiling when error, dumping class files with problem methods or problem types. This is recommanded only if you want
215 :     to be able to run your application even if you have remaining errors.</td>
216 :     </tr>
217 :     <tr>
218 :     <td valign=top>-verbose</td>
219 :     <td>Print accessed/processed compilation units in the console or the log file if specified.</td>
220 :     </tr>
221 :     <tr>
222 :     <td valign=top>-referenceInfo</td>
223 :     <td>Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.</td>
224 :     </tr>
225 :     <tr>
226 :     <td valign=top>-progress</td>
227 :     <td>Show progress (only in -log mode)</td>
228 :     </tr>
229 :     <tr>
230 :     <td valign=top>-time
231 :     </td>
232 :     <td>Display speed information</td>
233 :     </tr>
234 :     <tr>
235 :     <td valign=top>-noExit</td>
236 :     <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>
237 :     </tr>
238 :     <tr>
239 :     <td valign=top>-repeat &lt;n&gt;
240 :     </td>
241 :     <td>Repeat compilation process <font color="#3366FF">&lt;n&gt;</font> times (perf analysis).</td>
242 :     </tr>
243 :     </table>
244 :     </blockquote>
245 :     </td>
246 :     </tr>
247 :     <tr>
248 :     <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
249 :    
250 :     <td WIDTH="98%"><b>Examples</b>
251 :     <blockquote>
252 :     <table>
253 :     <td valign=top><font color="#3366FF">d:\temp -classpath rt.jar -time -g -d d:/tmp</font>
254 :     </td>
255 :     <td valign=top>It compiles all source files in d:\temp and its subfolders. The classpath is simply rt.jar. It generates all debug
256 :     attributes and all generated .class files are dumped in d:\tmp. The speed of the compiler will be displayed once the batch process
257 :     is completed.</td>
258 :     </tr>
259 :     <tr>
260 :     <td valign=top><font color="#3366FF">d:\temp\Test.java -classpath d:\temp;rt.jar -g:none</font>
261 :     </td>
262 :     <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
263 :     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>
264 :     </table>
265 :     </blockquote>
266 :     </td>
267 :     </tr>
268 :    
269 :     </table>
270 :    
271 :    
272 :    
273 :     </body>
274 :     </html>