Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Installing ANT on Windows and or Mac OS X

I'm gonna try and cover the two OS's here so be kind.

First things first, goto http://ant.apache.org/bindownload.cgi and download the appropriate archive (zip) file: apache-ant-[VERSION NUMBER HERE]-bin.zip

Then for Windows: Extract the .zip to c:\ant. From the command line set the following environment variables:

view plain print about
1set ANT_HOME=c:\ant
2set JAVA_HOME=c:\jdk-1.5.0.05
3set PATH=%PATH%;%ANT_HOME%\bin
For Mac: Unpack the zip file to /usr/local/ant/. Then from the command line set the following environment variables:
view plain print about
1export ANT_HOME=/usr/local/ant
2export PATH=${PATH}:${ANT_HOME}/bin

Now open up the Terminal(Mac)/Command line(Win) and just type "ANT" and hit return. You should see:

view plain print about
1Buildfile: build.xml does not exist!
2Build failed

To demonstrate calling a file we're gonna create a quick build.xml. Create a new text file, enter the following bit of XML and save it as build.xml

view plain print about
1<?xml version="1.0" encoding="UTF-8"?>
2<project name="myProject" default="runEcho" basedir=".">
3    <target name="runEcho">
4        <!-- Simply echo's a message to the screen -->
5        <echo message="Is anybody out there"/>
6    </target>
7</project>

If you are on Windows save this file to the root of c:\ and from the command line run the following

view plain print about
1ant -buildfile c:\build.xml

If you are on Mac then just save this to the desktop and from the Terminal run:
view plain print about
1ant -buildfile ~/desktop/build.xml
You should now see
view plain print about
1Buildfile: {PATH_TO_YOU_BUILD_FILE}build.xml
2
3runEcho:
4[echo] Is anybody out there
5
6BUILD SUCCESSFUL
7Total time: 0 seconds

That's pretty much it, from here you you are now set to run Ant from the Terminal/Command line so in theory you should be able to schedule tasks etc!

Comments Comments (15) | Print Print | Send Send | 9285 Views

If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck.

Related Blog Entries
(Comment Moderation is enabled. Your comment will not appear until approved.)
Andy?............. Go celebrate mate and leave this nerdy stuff alone for a while ;)
Don't worry Kev, the alcohol hasn't stopped .. i'm just slowly building up to prepare my body for some abusive drinking come the weekend
If he was a real nerd he would have proposed with a build.xml file :) I'll add this to my wiki!
In my nerd days, I once asked my girlfriend on a date using the Wizard from Microsoft Agent :P

http://www.microsoft.com/msagent/default.asp
If Andy was a real nerd he wouldn't be able to approach a girl to start with ;)
I did consider building a CFC that would except her answer as a boolean and only return it to me as a true value ... no chance of unexpected bugs then
Anyone know if you can pass in attributes to the build.xml file?
@Critter, easier to explain in a post :o)
http://www.andyjarrett.co.uk/andy/blog/index.cfm/2...
aye.

danke
Here's a windows installer for Ant that I made: http://code.google.com/p/winant/
I hope it's useful, and let me know if you'd like to develop it further.
Johnny Metal's Gravatar Posted By Johnny Metal @ 5/17/08 2:40 AM
Very usefull, thanks a lot!
Sriram Rajagopalan's Gravatar Posted By Sriram Rajagopalan @ 5/28/09 8:38 PM
Thanks Andy for this tutorial.
Really Helped me.. someone new to ANT.
Cheers !!!
Sriram
rashmi's Gravatar Posted By rashmi @ 4/18/10 7:47 PM
im not able to buildfile using xml program given in this site..... can u please help me building file
suresh's Gravatar Posted By suresh @ 6/25/10 2:16 PM
Hi Andy,

I have installed ant 1.8.1 on my Windows XP and set the path varieable to the bin folder of ant.
But, when i typed 'ant' in command line i am getting this error messaeg-
'ant' is not recognized as an internal or external command,
operable program or batch file.

Can you please help me in this ?
@suresh I haven't been on Windows for a while. First off have you tried a reboot and checked that the variable paths were saved?
BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .