How to install Apache Ant on Windows

To install Apache Ant on Windows, you just need to download the Ant’s zip file, and Unzip it, and configure the ANT_HOME Windows environment variables.

Tools Used :

  1. JDK 1.7
  2. Apache Ant 1.9.4
  3. Windows 8.1

1. JAVA_HOME

Make sure JDK is installed, and JAVA_HOME is configured as Windows environment variable.

install-ant-on-windows-1

2. Download Apache Ant

Visit Apache Ant official website, download the Ant binary zip file, for example : apache-ant-1.9.4-bin.zip, unzip it to the folder you want to store Apache Ant.

install-ant-on-windows-2

Assume you unzip to this folder – C:\apache-ant-1.9.4

install-ant-on-windows-3

3. Add ANT_HOME

Add ANT_HOME as the Windows environment variable, and point it to your Ant folder.

install-ant-on-windows-4

4. Update PATH

Update PATH variable, append %ANT_HOME%\bin at the end, so that you can run the Ant’s command everywhere.

install-ant-on-windows-5

5. Verification


C:\Users\mkyong>ant -v
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

If you see a similar message above, means the Apache Ant is installed successfully on Windows.

References

  1. Install Apache Ant

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

51 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Anda
8 years ago

Hello,

Thanks for tutorial.
Did you know what is explanation for?

Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

LaDO
8 years ago

Verification should not to be done with “ant -v” !
Flag -v means verbose
Instead “ant -version” should to be used for verification.

Mayank
8 years ago

can you also provide the reference for msbuild Ant tutorial

NDONG Michel
4 years ago

Thank you for this nice work

Philippe MEYER
5 years ago

thank you

Sonny
5 years ago

Thank you!

Ernesto
6 years ago

C:\>ant -version
‘ant’ n’est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

Swathi H
5 years ago
Reply to  Ernesto

1.Go to Apache bin folder
2.Find ant windows bat file
3.Right click and run as Admin
4.Now go to command prompt
5.Then check ant -v

Saket T
5 years ago
Reply to  Swathi H

Thanks !!

Rodrigo
6 years ago

Thank you! Mkyong.com rules. Best answers for my googles searches (on Java subject) usually goes for this site. Nice work! Congratulations.

cagrisma
7 years ago

thank youu

Soon
7 years ago

Thanks

Vinoth
7 years ago

Nice tutor. worked well.

Gabriel Andrade Valluis
7 years ago

THANK YOU ORIENT MASTER

Lisa
7 years ago

Thank you! Seriously, the Apache Ant site should just link to this page for the install instructions.

guest
7 years ago

i get createprocess error=2 on building tasks, help could be appreciated

Rangavalli Mounika
7 years ago

Getting this error while checking ant -v
%JAVA_HOME%\lib\tools.jar was unexpected at this time.

swapna
7 years ago

I had to restart my machine after making changes to environment variables.

Mariam Ahmed Moustafa
7 years ago

Thanks

Guest
8 years ago

Thanks!

Angad
8 years ago

Thanks ! it was 5 am in the morning and this post helped me a lot!

Mohan
8 years ago

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:UsersUser>ant -v
Unable to locate tools.jar. Expected to find it in C:Program FilesJavajre1.8.
0_131libtools.jar
Apache Ant(TM) version 1.9.7 compiled on April 9 2016
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed

Please help me, i got it while i am doing according your instructions….

SB
9 years ago

When i verify I am getting the following exception:

java.lang.ClassCastException: org.apache.tools.ant.Main cannot be cast to org.ap
ache.tools.ant.launch.AntMain
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
ant.home: C:[HIDDEN_PATH]apache-ant-1.9.7
Classpath: C:[HIDDEN_PATH]apache-ant-1.9.7libant-launcher.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-antlr.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-bcel.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-bsf.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-log4j.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-oro.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-regexp.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-resolver.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-apache-xalan2.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-commons-logging.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-commons-net.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-jai.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-javamail.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-jdepend.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-jmf.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-jsch.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-junit.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-junit4.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-launcher.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-netrexx.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-swing.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant-testutil.jar;
C:[HIDDEN_PATH]apache-ant-1.9.7libant.jar;
C:Javajdk1.7.0_80libtools.jar
Launcher JAR: C:[HIDDEN_PATH]apache-ant-1.9.7libant-launcher.jar
Launcher Directory: C:[HIDDEN_PATH]apache-ant-1.9.7lib

Please help.

Anonyous
9 years ago

So easy, thanks !!!

crop1645
9 years ago

Simple, easy to follow, and worked first time.

mahesh basapur
9 years ago

Thank you

Afrah Salman
9 years ago

Hi, can you please tell me where should I found the verification message?
I follow all your steps but I don’t know where should the verification message appear…
I need your help please.

Klepa
9 years ago

Perfect, thank you

pobby69
9 years ago

Thanks for this.

Brice Edem Lossou
9 years ago

Thanks !

stackCrawler
10 years ago

Thanks!

Ario
10 years ago

thanks