As I'm currently in the process of building a new developer machine I thought I'd take the time to document installing one of my favorite tools ANT.
ANT (Another Neat Tool) is a build tool which allows you to automate the process of building, testing and deploying a software project. As it is a java tool it runs anywhere, but since I work mainly on windows I'm going to detail how to install it on windows.
The first step to installing ANT is actually to install the java JDK. Go to the Oracle JDK Download Page and download the 32-bit JDK installer (I have encountered problems with the 64-bit version in the past which may or may not have been fixed).
Run the installer and note the install directory for later. My own install ended up at "c:\Program Files\java\jdk[version number]"
With java installed go ahead and download the latest ANT build zip file from the ANT Download Page. Then simply extract the zip file to a convenient location. I placed mine at "C:\ant".
Now we need to setup three system variables.
For my install I used the following values.
To check to see if these are already defined open a command prompt and run the following commands.
echo %JAVA_HOME%
echo %ANT_HOME%
echo %PATH%
If they are not already setup we have two options to define them.
To use the windows gui to setup these variables open "control panel > system > advanced system settings". Select the "advanced" tab and click on "environment variables".
Add two new user variables "ANT_HOME" and "JAVA_HOME" with their respective values.
Then edit the system variable "PATH" and add ";c:\ant\bin" to it.
A simpler way to accomplish the same thing is to open a command prompt window (with admin rights) and run the following commands. Remember to modify the values to match your configuration.
set ANT_HOME=c:\ant
set JAVA_HOME=c:\Program Files\Java\jdk1.6.0_24
set PATH=%PATH%;%ANT_HOME%\bin
To test if ant is installed correctly all we need to do is open a command prompt and run the "ant" command. If everything is setup correctly you should see this message.
C:\Windows\System32>ant
Buildfile: build.xml does not exist!
Build Failed
What this means is that ant is running but there currently is no buildfile (build.xml) for it to run. This is exactly what you would expect to happen for a new install with no software projects with build files to run.
If when you ran the ant command you get the following error you need to check that the JAVA_HOME variable is pointing to the JDK directory and not the JRE directory.
Note how the tools.jar path reads "jre6" and not "jdk6".
C:\>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li
b\tools.jar
Buildfile: build.xml does not exist!
Build failed
So there you have it, ANT installed and running on windows. In a later post I'll show you how to hook up eclipse to use it.