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

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
35 Comment threads
1 Thread replies
1 Followers
 
Most reacted comment
Hottest comment thread
35 Comment authors
Rangavalli MounikaswapnaMariam Ahmed MoustafaClark ElliottSiv Recent comment authors
newest oldest most voted
LaDO
Guest
LaDO

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

ADONGO JUSTICE
Guest
ADONGO JUSTICE

Thanks, saved my sunday

hnnry
Guest
hnnry

THANKS A LOT MAN!

Mark
Guest
Mark

Excellent Tutorial. Thank you very much

Mayank
Guest
Mayank

can you also provide the reference for msbuild Ant tutorial

Guest
Guest
Guest

Thanks!

Angad
Guest
Angad

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

Anda
Guest
Anda

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

Mohan
Guest
Mohan

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
Guest
SB

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
Guest
Anonyous

So easy, thanks !!!

crop1645
Guest
crop1645

Simple, easy to follow, and worked first time.

mahesh basapur
Guest
mahesh basapur

Thank you

Afrah Salman
Guest
Afrah Salman

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
Guest
Klepa

Perfect, thank you

pobby69
Guest
pobby69

Thanks for this.

Brice Edem Lossou
Guest
Brice Edem Lossou

Thanks !

stackCrawler
Guest
stackCrawler

Thanks!

Ario
Guest
Ario

thanks

Niranjan Sahu
Guest
Niranjan Sahu

Thanks A lot..

Mitul Thesiya
Guest
Mitul Thesiya

Thanks a lot..

Claudio Daffra
Guest
Claudio Daffra

Thank you very much !

Nadia Yusof
Guest
Nadia Yusof

thank youuu

Stuart Robinson
Guest
Stuart Robinson

thank you!

Bogdan
Guest
Bogdan

Thanks!!!!!!!!!!

kate
Guest
kate

Thank you so much! Your site is really great!!! mark it in my favor bookmark…and reference all the time when hit a Java programming issue!!!

Dheeraj Vashist
Guest
Dheeraj Vashist

Thank you from India :)

Sivakanth Reddy
Guest
Sivakanth Reddy

works for me,thanks

Diego Manuel Benitez Enciso
Guest
Diego Manuel Benitez Enciso

muchas gracias por el tutorial

Diego Manuel Benitez Enciso
Guest
Diego Manuel Benitez Enciso

este es el mejor sitio, y el mas util, sobre java

mkyong
Guest
mkyong

gracias