You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

running.html 22 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
  5. <title>Running Apache Ant</title>
  6. </head>
  7. <body>
  8. <h1>Running Ant</h1>
  9. <h2><a name="commandline">Command Line</a></h2>
  10. <p> If you've installed Ant as described in the
  11. <a href="install.html"> Installing Ant</a> section,
  12. running Ant from the command-line is simple: just type
  13. <code>ant</code>.</p>
  14. <p>When no arguments are specified, Ant looks for a <code>build.xml</code>
  15. file in the current directory and, if found, uses that file as the
  16. build file and runs the target specified in the <code>default</code>
  17. attribute of the <code>&lt;project&gt;</code> tag.
  18. To make Ant use
  19. a build file other than <code>build.xml</code>, use the command-line
  20. option <nobr><code>-buildfile <i>file</i></code></nobr>,
  21. where <i>file</i> is the name of the build file you want to use.</p>
  22. If you use the <nobr><code>-find [<i>file</i>]</code></nobr> option,
  23. Ant will search for a build file first in the current directory, then in
  24. the parent directory, and so on, until either a build file is found or the root
  25. of the filesystem has been reached. By default, it will look for a build file
  26. called <code>build.xml</code>. To have it search for a build file other
  27. than <code>build.xml</code>, specify a file argument.
  28. <strong>Note:</strong> If you include any other flags or arguments
  29. on the command line after
  30. the <nobr><code>-find</code></nobr> flag, you must include the file argument
  31. for the <nobr><code>-find</code></nobr> flag, even if the name of the
  32. build file you want to find is <code>build.xml</code>.
  33. <p>You can also set <a href="using.html#properties">properties</a> on the
  34. command line. This can be done with
  35. the <nobr><code>-D<i>property</i>=<i>value</i></code></nobr> option,
  36. where <i>property</i> is the name of the property,
  37. and <i>value</i> is the value for that property. If you specify a
  38. property that is also set in the build file
  39. (see the <a href="CoreTasks/property.html">property</a> task),
  40. the value specified on the
  41. command line will override the value specified in the
  42. build file.
  43. Defining properties on the command line can also be used to pass in
  44. the value of environment variables; just pass
  45. <nobr><code>-DMYVAR=%MYVAR%</code></nobr> (Windows) or
  46. <nobr><code>-DMYVAR=$MYVAR</code></nobr> (Unix)
  47. to Ant. You can then access
  48. these variables inside your build file as <code>${MYVAR}</code>.
  49. You can also access environment variables using the
  50. <a href="CoreTasks/property.html"> property</a> task's
  51. <code>environment</code> attribute.
  52. </p>
  53. <p>Options that affect the amount of logging output by Ant are:
  54. <nobr><code>-quiet</code></nobr>,
  55. which instructs Ant to print less
  56. information to the console;
  57. <nobr><code>-verbose</code></nobr>, which causes Ant to print
  58. additional information to the console; and <nobr><code>-debug</code></nobr>,
  59. which causes Ant to print considerably more additional information.
  60. </p>
  61. <p>It is also possible to specify one or more targets that should be executed.
  62. When omitted, the target that is specified in the
  63. <code>default</code> attribute of the
  64. <a href="using.html#projects"><code>project</code></a> tag is
  65. used.</p>
  66. <p>The <nobr><code>-projecthelp</code></nobr> option prints out a list
  67. of the build file's targets. Targets that include a
  68. <code>description</code> attribute are listed as &quot;Main targets&quot;,
  69. those without a <code>description</code> are listed as
  70. &quot;Other targets&quot;, then the &quot;Default&quot; target is listed
  71. ("Other targets" are only displayed if there are no main
  72. targets, or if Ant is invoked in -verbose or -debug mode).
  73. <h3><a name="options">Command-line Options Summary</a></h3>
  74. <pre>ant [options] [target [target2 [target3] ...]]
  75. Options:
  76. -help, -h print this message
  77. -projecthelp, -p print project help information
  78. -version print the version information and exit
  79. -diagnostics print information that might be helpful to
  80. diagnose or report problems.
  81. -quiet, -q be extra quiet
  82. -verbose, -v be extra verbose
  83. -debug, -d print debugging information
  84. -emacs, -e produce logging information without adornments
  85. -lib &lt;path&gt; specifies a path to search for jars and classes
  86. -logfile &lt;file&gt; use given file for log
  87. -l &lt;file&gt; ''
  88. -logger &lt;classname&gt; the class which is to perform logging
  89. -listener &lt;classname&gt; add an instance of class as a project listener
  90. -noinput do not allow interactive input
  91. -buildfile &lt;file&gt; use given buildfile
  92. -file &lt;file&gt; ''
  93. -f &lt;file&gt; ''
  94. -D&lt;property&gt;=&lt;value&gt; use value for given property
  95. -keep-going, -k execute all targets that do not depend
  96. on failed target(s)
  97. -propertyfile &lt;name&gt; load all properties from file with -D
  98. properties taking precedence
  99. -inputhandler &lt;class&gt; the class which will handle input requests
  100. -find &lt;file&gt; (s)earch for buildfile towards the root of
  101. -s &lt;file&gt; the filesystem and use it
  102. -nice number A niceness value for the main thread:
  103. 1 (lowest) to 10 (highest); 5 is the default
  104. -nouserlib Run ant without using the jar files from ${user.home}/.ant/lib
  105. -noclasspath Run ant without using CLASSPATH
  106. </pre>
  107. <p>For more information about <code>-logger</code> and
  108. <code>-listener</code> see
  109. <a href="listeners.html">Loggers &amp; Listeners</a>.
  110. <p>For more information about <code>-inputhandler</code> see
  111. <a href="inputhandler.html">InputHandler</a>.
  112. <h3><a name="libs">Library Directories</a></h3>
  113. <p>
  114. Prior to Ant 1.6, all jars in the ANT_HOME/lib would be added to the CLASSPATH
  115. used to run Ant. This was done in the scripts that started Ant. From Ant 1.6,
  116. two directories are scanned by default and more can be added as required. The
  117. default directories scanned are ANT_HOME/lib and a user specific directory,
  118. ${user.home}/.ant/lib. This arrangement allows the Ant installation to be
  119. shared by many users while still allowing each user to deploy additional jars.
  120. Such additional jars could be support jars for Ant's optional tasks or jars
  121. containing third-party tasks to be used in the build. It also allows the main Ant installation to be locked down which will please system adminstrators.
  122. </p>
  123. <p>
  124. Additional directories to be searched may be added by using the -lib option.
  125. The -lib option specifies a search path. Any jars or classes in the directories
  126. of the path will be added to Ant's classloader. The order in which jars are
  127. added to the classpath is as follows:
  128. </p>
  129. <ul>
  130. <li>-lib jars in the order specified by the -lib elements on the command line</li>
  131. <li>jars from ${user.home}/.ant/lib (unless -nouserlib is set)</li>
  132. <li>jars from ANT_HOME/lib</li>
  133. </ul>
  134. <p>
  135. Note that the CLASSPATH environment variable is passed to Ant using a -lib
  136. option. Ant itself is started with a very minimalistic classpath.
  137. Ant should work perfectly well with an empty CLASSPATH environment variable,
  138. something the the -noclasspath option actually enforces. We get many more support calls related to classpath problems (especially quoting problems) than
  139. we like.
  140. </p>
  141. <p>
  142. The location of ${user.home}/.ant/lib is somewhat dependent on the JVM. On Unix
  143. systems ${user.home} maps to the user's home directory whilst on recent
  144. versions of Windows it will be somewhere such as
  145. C:\Documents&nbsp;and&nbsp;Settings\username\.ant\lib. You should consult your
  146. JVM documentation for more details.
  147. </p>
  148. <h3>Examples</h3>
  149. <blockquote>
  150. <pre>ant</pre>
  151. </blockquote>
  152. <p>runs Ant using the <code>build.xml</code> file in the current directory, on
  153. the default target.</p>
  154. <blockquote>
  155. <pre>ant -buildfile test.xml</pre>
  156. </blockquote>
  157. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  158. the default target.</p>
  159. <blockquote>
  160. <pre>ant -buildfile test.xml dist</pre>
  161. </blockquote>
  162. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  163. the target called <code>dist</code>.</p>
  164. <blockquote>
  165. <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
  166. </blockquote>
  167. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  168. the target called <code>dist</code>, setting the <code>build</code> property
  169. to the value <code>build/classes</code>.</p>
  170. <blockquote>
  171. <pre>ant -lib /home/ant/extras</pre>
  172. </blockquote>
  173. <p>runs Ant picking up additional task and support jars from the
  174. /home/ant/extras location
  175. </p>
  176. <h3><a name="files">Files</a></h3>
  177. <p>The Ant wrapper script for Unix will source (read and evaluate) the
  178. file <code>~/.antrc</code> before it does anything. On Windows, the Ant
  179. wrapper batch-file invokes <code>%HOME%\antrc_pre.bat</code> at the start and
  180. <code>%HOME%\antrc_post.bat</code> at the end. You can use these
  181. files, for example, to set/unset environment variables that should only be
  182. visible during the execution of Ant. See the next section for examples.</p>
  183. <h3><a name="envvars">Environment Variables</a></h3>
  184. <p>The wrapper scripts use the following environment variables (if
  185. set):</p>
  186. <ul>
  187. <li><code>JAVACMD</code> - full path of the Java executable. Use this
  188. to invoke a different JVM than <code>JAVA_HOME/bin/java(.exe)</code>.</li>
  189. <li><code>ANT_OPTS</code> - command-line arguments that should be
  190. passed to the JVM. For example, you can define system properties or set
  191. the maximum Java heap size here.</li>
  192. <li><code>ANT_ARGS</code> - Ant command-line arguments. For example,
  193. set <code>ANT_ARGS</code> to point to a different logger, include a
  194. listener, and to include the <code>-find</code> flag.</li>
  195. <strong>Note:</strong> If you include <code>-find</code>
  196. in <code>ANT_ARGS</code>, you should include the name of the build file
  197. to find, even if the file is called <code>build.xml</code>.
  198. </ul>
  199. <h3><a name="sysprops">Java System Properties</a></h3>
  200. <p>Some of Ant's core classes can be configured via system properties.</p>
  201. <p>Here is the result of a search through the codebase. Because system properties are
  202. available via Project instance, I searched for them with a
  203. <pre>
  204. grep -r -n "getPropert" * &gt; ..\grep.txt
  205. </pre>
  206. command. After that I filtered out the often-used but not-so-important values (most of them
  207. read-only values): <i>path.separator, ant.home, basedir, user.dir, os.name,
  208. line.separator, java.home, java.version, java.version, user.home, java.class.path</i><br>
  209. And I filtered out the <i>getPropertyHelper</i> access.</p>
  210. <table border="1">
  211. <tr>
  212. <th>property name</th>
  213. <th>valid values /default value</th>
  214. <th>description</th>
  215. </tr>
  216. <tr>
  217. <td><code>ant.build.javac.source</code></td>
  218. <td>Source-level version number</td>
  219. <td>Default <em>source</em> value for &lt;javac&gt;/&lt;javadoc&gt;</td>
  220. </tr>
  221. <tr>
  222. <td><code>ant.build.javac.target</code></td>
  223. <td>Class-compatibility version number</td>
  224. <td>Default <em>target</em> value for &lt;javac&gt;</td>
  225. </tr>
  226. <tr>
  227. <td><code>ant.executor.class</code></td>
  228. <td>classname; default is org. apache. tools. ant. helper. DefaultExecutor</td>
  229. <td><b>Since Ant 1.6.3</b> Ant will delegate Target invocation to the
  230. org.apache.tools.ant.Executor implementation specified here.
  231. </td>
  232. </tr>
  233. <tr>
  234. <td><code>ant.file</code></td>
  235. <td>read only: full filename of the build file</td>
  236. <td>This is set to the name of the build file. In
  237. <a href="CoreTasks/import.html">
  238. &lt;import&gt;-ed</a> files, this is set to the containing build file.
  239. </td>
  240. </tr>
  241. <tr>
  242. <td><code>ant.file.*</code></td>
  243. <td>read only: full filename of the build file of Ant projects
  244. </td>
  245. <td>This is set to the name of a file by project;
  246. this lets you determine the location of <a href="CoreTasks/import.html">
  247. &lt;import&gt;-ed</a> files,
  248. </td>
  249. </tr>
  250. <tr>
  251. <td><code>ant.input.properties</code></td>
  252. <td>filename (required)</td>
  253. <td>Name of the file holding the values for the
  254. <a href="inputhandler.html">PropertyFileInputHandler</a>.
  255. </td>
  256. </tr>
  257. <tr>
  258. <td><code>ant.logger.defaults</code></td>
  259. <!-- add the blank after the slash, so the browser can do a line break -->
  260. <td>filename (optional, default '/org/ apache/ tools/ ant/ listener/ defaults.properties')</td>
  261. <td>Name of the file holding the color mappings for the
  262. <a href="listeners.html#AnsiColorLogger">AnsiColorLogger</a>.
  263. </td>
  264. </tr>
  265. <tr>
  266. <td><code>ant.netrexxc.*</code></td>
  267. <td>several formats</td>
  268. <td>Use specified values as defaults for <a href="OptionalTasks/netrexxc.html">netrexxc</a>.
  269. </td>
  270. </tr>
  271. <tr>
  272. <td><code>ant.PropertyHelper</code></td>
  273. <td>ant-reference-name (optional)</td>
  274. <td>Specify the PropertyHelper to use. The object must be of the type
  275. org.apache.tools.ant.PropertyHelper. If not defined an object of
  276. org.apache.tools.ant.PropertyHelper will be used as PropertyHelper.
  277. </td>
  278. </tr>
  279. <tr>
  280. <td><code>ant.regexp.regexpimpl</code></td>
  281. <td>classname</td>
  282. <td>classname for a RegExp implementation; if not set Ant tries to
  283. find another (JDK14+, Apache Oro...);
  284. <a href="CoreTypes/mapper.html#regexp-mapper">RegExp-Mapper</a>
  285. "Choice of regular expression implementation"
  286. </td>
  287. </tr>
  288. <tr>
  289. <td><code>ant.reuse.loader</code></td>
  290. <td>boolean</td>
  291. <td>allow to reuse classloaders
  292. used in org.apache.tools.ant.util.ClasspathUtil
  293. </td>
  294. </tr>
  295. <tr>
  296. <td><code>ant.XmlLogger.stylesheet.uri</code></td>
  297. <td>filename (default 'log.xsl')</td>
  298. <td>Name for the stylesheet to include in the logfile by
  299. <a href="listeners.html#XmlLogger">XmlLogger</a>.
  300. </td>
  301. </tr>
  302. <tr>
  303. <td><code>build.compiler</code></td>
  304. <td>name</td>
  305. <td>Specify the default compiler to use.
  306. see <a href="CoreTasks/javac.html">javac</a>,
  307. <a href="OptionalTasks/ejb.html#ejbjar_weblogic">EJB Tasks</a>
  308. (compiler attribute),
  309. <a href="OptionalTasks/javah.html">javah</a>
  310. </td>
  311. </tr>
  312. <tr>
  313. <td><code>build.compiler.emacs</code></td>
  314. <td>boolean (default false)</td>
  315. <td>Enable emacs-compatible error messages.
  316. see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes"
  317. </td>
  318. </tr>
  319. <tr>
  320. <td><code>build.compiler.fulldepend</code></td>
  321. <td>boolean (default false)</td>
  322. <td>Enable full dependency checking
  323. see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes"
  324. </td>
  325. </tr>
  326. <tr>
  327. <td><code>build.compiler.jvc.extensions</code></td>
  328. <td>boolean (default true)</td>
  329. <td>enable Microsoft extensions of their java compiler
  330. see <a href="CoreTasks/javac.html">javac</a> "Jvc Notes"
  331. </td>
  332. </tr>
  333. <tr>
  334. <td><code>build.compiler.pedantic</code></td>
  335. <td>boolean (default false)</td>
  336. <td>Enable pedantic warnings.
  337. see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes"
  338. </td>
  339. </tr>
  340. <tr>
  341. <td><code>build.compiler.warnings</code></td>
  342. <td>Deprecated flag</td>
  343. <td> see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes" </td>
  344. </tr>
  345. <tr>
  346. <td><code>build.rmic</code></td>
  347. <td>name</td>
  348. <td>control the <a href="CoreTasks/rmic.html">rmic</a> compiler </td>
  349. </tr>
  350. <tr>
  351. <td><code>build.sysclasspath</code></td>
  352. <td>"only", something else</td>
  353. <td>only: current threads get the actual class loader
  354. (AntClassLoader.setThreadContextLoader()).
  355. else: use core loader as default (ComponentHelper.initTasks()). Disable
  356. changing the classloader (oata.taskdefs.Classloader.execute() experimental
  357. task).
  358. <!-- somewhere documented in the manual?? -->
  359. </td>
  360. </tr>
  361. <tr>
  362. <td><code>file.encoding</code></td>
  363. <td>name of a supported character set (e.g. UTF-8, ISO-8859-1, US-ASCII)</td>
  364. <td>use as default character set of email messages; use as default for source-, dest- and bundleencoding
  365. in <a href="OptionalTasks/translate.html">translate</a> <br>
  366. see JavaDoc of <a target="_blank" href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">java.nio.charset.Charset</a>
  367. for more information about character sets (not used in Ant, but has nice docs).
  368. </td>
  369. </tr>
  370. <tr>
  371. <td><code>jikes.class.path</code></td>
  372. <td>path</td>
  373. <td>The specified path is added to the classpath if jikes is used as compiler.</td>
  374. </tr>
  375. <tr>
  376. <td><code>MailLogger.properties.file, MailLogger.*</code></td>
  377. <td>filename (optional, defaults derived from Project instance)</td>
  378. <td>Name of the file holding properties for sending emails by the
  379. <a href="listeners.html#MailLogger">MailLogger</a>. Override properties set
  380. inside the buildfile or via command line.
  381. </td>
  382. </tr>
  383. <tr>
  384. <td><code>org.apache.tools.ant.ProjectHelper</code></td>
  385. <!-- add the blank after the slash, so the browser can do a line break -->
  386. <td>classname (optional, default 'org.apache.tools.ant.ProjectHelper')</td>
  387. <td>specifies the classname to use as ProjectHelper. The class must extend
  388. org.apache.tools.ant.ProjectHelper.
  389. </td>
  390. </tr>
  391. <tr>
  392. <td><code>p4.port, p4.client, p4.user</code></td>
  393. <td>several formats</td>
  394. <td>Specify defaults for port-, client- and user-setting of the
  395. <a href="OptionalTasks/perforce.html">perforce</a> tasks.
  396. </td>
  397. </tr>
  398. <tr>
  399. <td><code>websphere.home
  400. <td>path</td>
  401. <td>Points to home directory of websphere.
  402. see <a href="OptionalTasks/ejb.html#ejbjar_websphere">EJB Tasks</a>
  403. </td>
  404. </tr>
  405. <tr>
  406. <td><code>XmlLogger.file
  407. <td>filename (default 'log.xml')</td>
  408. <td>Name for the logfile for <a href="listeners.html#MailLogger">MailLogger</a>.
  409. </td>
  410. </tr>
  411. </table>
  412. <p>
  413. If new properties get added (it happens), expect them to appear under the
  414. "ant." and "org.apache.tools.ant" prefixes, unless the developers have a
  415. very good reason to use another prefix. Accordingly, please avoid using
  416. properties that begin with these prefixes. This protects you from future
  417. Ant releases breaking your build file.
  418. </p>
  419. <h3>return code</h3>
  420. <p>the ant start up scripts (in their Windows and Unix version) return
  421. the return code of the java program. So a successful build returns 0,
  422. failed builds return other values.
  423. </p>
  424. <p>Under Windows95 and 98, a special environment variable ANT_ERROR will be set
  425. by the script ant.bat, because it is not possible to exit the script with a
  426. specific errorlevel.</p>
  427. <h2><a name="cygwin">Cygwin Users</a></h2>
  428. <p>The Unix launch script that come with Ant works correctly with Cygwin. You
  429. should not have any problems launching Ant from the Cygwin shell. It is
  430. important to note, however, that once Ant is running it is part of the JDK
  431. which operates as a native Windows application. The JDK is not a Cygwin
  432. executable, and it therefore has no knowledge of Cygwin paths, etc. In
  433. particular when using the <code>&lt;exec&gt;</code> task, executable names such
  434. as &quot;/bin/sh&quot; will not work, even though these work from the Cygwin
  435. shell from which Ant was launched. You can use an executable name such as
  436. &quot;sh&quot; and rely on that command being available in the Windows path.
  437. </p>
  438. <h2><a name="os2">OS/2 Users</a></h2>
  439. <p>The OS/2 launch script was developed to perform complex tasks. It has two parts:
  440. <code>ant.cmd</code> which calls Ant and <code>antenv.cmd</code> which sets the environment for Ant.
  441. Most often you will just call <code>ant.cmd</code> using the same command line options as described
  442. above. The behaviour can be modified by a number of ways explained below.</p>
  443. <p>Script <code>ant.cmd</code> first verifies whether the Ant environment is set correctly. The
  444. requirements are:</p>
  445. <ol>
  446. <li>Environment variable <code>JAVA_HOME</code> is set.</li>
  447. <li>Environment variable <code>ANT_HOME</code> is set.</li>
  448. <li>Environment variable <code>CLASSPATH</code> is set and contains at least one element from
  449. <code>JAVA_HOME</code> and at least one element from <code>ANT_HOME</code>.</li>
  450. </ol>
  451. <p>If any of these conditions is violated, script <code>antenv.cmd</code> is called. This script
  452. first invokes configuration scripts if there exist: the system-wide configuration
  453. <code>antconf.cmd</code> from the <code>%ETC%</code> directory and then the user configuration
  454. <code>antrc.cmd</code> from the <code>%HOME%</code> directory. At this moment both
  455. <code>JAVA_HOME</code> and <code>ANT_HOME</code> must be defined because <code>antenv.cmd</code>
  456. now adds <code>classes.zip</code> or <code>tools.jar</code> (depending on version of JVM) and
  457. everything from <code>%ANT_HOME%\lib</code> except <code>ant-*.jar</code> to
  458. <code>CLASSPATH</code>. Finally <code>ant.cmd</code> calls per-directory configuration
  459. <code>antrc.cmd</code>. All settings made by <code>ant.cmd</code> are local and are undone when the
  460. script ends. The settings made by <code>antenv.cmd</code> are persistent during the lifetime of the
  461. shell (of course unless called automatically from <code>ant.cmd</code>). It is thus possible to call
  462. <code>antenv.cmd</code> manually and modify some settings before calling <code>ant.cmd</code>.</p>
  463. <p>Scripts <code>envset.cmd</code> and <code>runrc.cmd</code> perform auxiliary tasks. All scripts
  464. have some documentation inside.</p>
  465. <h2><a name="viajava">Running Ant via Java</a></h2>
  466. <p>If you have installed Ant in the do-it-yourself way, Ant can be started
  467. from one of two entry points:</p>
  468. <blockquote>
  469. <pre>java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
  470. </blockquote>
  471. <blockquote>
  472. <pre>java -Dant.home=c:\ant org.apache.tools.ant.launch.Launcher [options] [target]</pre>
  473. </blockquote>
  474. <p>
  475. The first method runs Ant's traditional entry point. The second method uses
  476. the Ant Launcher introduced in Ant 1.6. The former method does not support
  477. the -lib option and all required classes are loaded from the CLASSPATH. You must
  478. ensure that all required jars are available. At a minimum the CLASSPATH should
  479. include:
  480. </p>
  481. <ul>
  482. <li><code>ant.jar</code> and <code>ant-launcher.jar</code></li>
  483. <li>jars/classes for your XML parser</li>
  484. <li>the JDK's required jar/zip files</li>
  485. </ul>
  486. <p>
  487. The latter method supports the -lib option and will load jars from the
  488. specified ANT_HOME. You should start the latter with the most minimal
  489. classpath possible, generally just the ant-launcher.jar.
  490. </p>
  491. <br>
  492. <hr>
  493. <p align="center">Copyright &copy; 2000-2006 The Apache Software Foundation. All rights
  494. Reserved.</p>
  495. </body>
  496. </html>