Apache - Ant - Installation

Ant is a Java tool that can help you building projects and setting them correctly.
It can generates files and directory from simple XML files.
So, let's get started with this tutorial of Apache Ant on Windows operating system.

1. Apache Ant installation on Windows

So, we will install Ant on Windows and for that we will use in this tutorial:

Two things are important, the path for the directory and the path for the environment variables.

A. The path for the directory

You must install Ant in a directory, and the path must not have any space inside.
For example: C:\Program Files (x86)\Apache Ant 1.8.2 is really bad!

Instead use this one: C:\soft\apache\ant-1.8.2

Because Ant does not accept spaces and quotes in its path.
And Windows will never find it when you will try to run it.

Do the same for Java SDK.
So if you already installed it in a path like this: C:\Program Files (x86)\Java\jdk 1.7.0, you have to uninstall and reinstall it in a new directory with a path like that: C:\soft\java\jdk1.7.0

B. The path for the environment variables

Now you have to set the environment variables correctly.

Click Start.
Under All Programs, there is a search input.
Write it inside: var

In the result, select: Edit the system environment variables

A new window appears.
This is the System Properties and the Advanced tab is already selected.
Click Environment Variable... at the bottom.

The Environment Variables window appears.

In the User variables for YOURNAME, click New...

In Variable name, enter: JAVA_HOME
In Variable value, enter: C:\soft\apache\ant-1.8.2

Click OK.

Reclick New...

In Variable name, enter: ANT_HOME
In Variable value, enter: C:\soft\java\jdk1.7.0

Click OK.

Reclick New...

In Variable name, enter: PATH
In Variable value, enter: %JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%;

Click OK to close this window and OK to close the System Properties one as well.

Now open a cmd line and write:

$ ant -v


Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

If you see this message above, Apache Ant is installed.
Well done! laugh

If not, restart your computer and try again the ant -v command.
If you still do not have this message, you missed something!
Try again all the installation and remove the values inside the CLASSPATH variables or removes quotes inside.
Good luck! blush

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.