Ant Installation - Web Tutorial
by Michael Thomas
Ant Home Page
Windows Download and Install (XP Pro)
- Download Ant - as of 04/27/08 - version 1.7.0
- http://ant.apache.org
- On the left side panel click "Binary Distributions" under Download
- apache-ant-1.7.0-bin.zip - (~11meg) - download this
file to any directory.
- Install Ant
- I'll step you through the install process.
(FYI - The online install guide is under the link: Documentation,
Manual, "Installing Ant".)
- There is no installation utility. You extract the zip file
into the directory you plan on using.
- Create the following directory: C:\java\apache\ant
- (Note: I wish windows used "programs" as the main directory and not
"Program Files")
- Windows Issues:
There is issues with Ant and long directory names (must conform to
format 8.3) because of a limitation in the "for" batch-file
statement
Also, you may need more environment space (we will cover this
later).
The Ant web site suggests: c:\ant (but I suggest the above)
- Extract the zip file into this directory.
- Add/Verify Environment System Variables
- Go to the Environment Variable add/edit screen:
Win XPPro: Settings, Control Panel, System, Advanced tab, click on
"Environment Variable" button
- Add the ANT_HOME environment system variable:
In the System Variable section, click "New"
Variable Name: ANT_HOME
Variable Value: C:\java\apache\ant\apache-ant-1.7.0
- Edit the PATH environment variable to include the ANT_HOME path:
Click on the variable "PATH", then click "Edit"
Add the following to the end of the current value:
;%ANT_HOME%\bin
- Verify/Add the JAVA_HOME environment system variable:
In the System Variable section, click "New"
Variable Name: JAVA_HOME
Variable Value: <Full path to the home directory of your JDK
install>
Ex: C:\Program Files\Java\jdk1.6.0_03
(Note: The Sun java installs (JDK and/or JRE) modifies the PATH
variable and does not create the variable "JAVA_HOME".)
- Older Windows Environments - config.sys
- For Windows NT and ME (and older) add the following to the
config.sys file (probably in the c:\ directory):
shell=c:\command.com c:\ /p /e:32768
- Install is finished, now test.
- Test your Install - find the ant version.
- At the Command Prompt (Run, cmd.exe), the command below should return similar
results.:
C:\>ant -version
Apache Ant version 1.7.0 compiled on December 13 2006
- Possible Errors:
- Possible errors corrected by completing the Environment
Variables section above. When correcting these errors make
sure you exit and re-launch the command prompt window.
- Error:
C:\>ant -version
'ant' is not recognized as an internal or external command,
operable program or batch file.
Note: Probably PATH related.
- Error:
C:\>ant -version
Unable to locate tools.jar. Expected to find it in C:\Program
Files\Java\jre1.6.0_03\lib\tools.jar
Apache Ant version 1.7.0 compiled on December 13 2006
Note: Probably JAVA_HOME related.
Point it to the JDK directory (not the JRE).
- Error:
C:\>ant -version
Access is denied.
Note: Probably JAVA_HOME related.
- ANT Docs
- ANT Version & Command Line Help
- Create and run the batch file "ant_help_commandline.bat" to see
Command Line Help for ANT (in the download!).
rem Note: ant will turn off commandline echo!
echo on
call ant -version
echo on
call ant -help
pause
- Finished Installation
- You have completed the Ant Install.
- Next, return to the Ant home page and continue with the next steps
in the tutorial.
- Miscellaneous Notes
- If you don't want to use Environment System Variables you can do the
following in a batch file:
set ANT_HOME=C:\java\apache\ant\apache-ant-1.7.0
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
set Path=%PATH%;%ANT_HOME%\bin
- Pre & Post batch files - before the Ant build is started "%HOME%\antrc_pre.bat"
is executed if it exists. After the Ant build has completed
"%HOME%\antrc_post.bat"
- XML Issues - Ant needs an XML parser. A parser is located in
the Ant/lib directory.
- Proxy Configurations - research the "ANT_OPTS" environment variable.