[ACCEPTED]-Error installing Ant: ANT_HOME is set incorrectly-ant

Accepted answer
Score: 103

It sounds like you have it setup right. What 3 happens if you try something like this, which 2 worked for me:

C:\>set ANT_HOME=C:\apache-ant-1.8.1

C:\>set JAVA_HOME=C:\jdk1.6.0_24

C:\>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

C:\>ant -version
Apache Ant version 1.8.1 compiled on April 30 2010

This also worked for me by 1 setting up environment variables, like so:

Ant Env

Score: 14

I had the exact same problem and came across 9 your post.

I figured out my problem was 8 that somehow I did not have a lib directory 7 in my ANT_HOME folder. It looks like the script 6 looks specifically for ant.jar. I unzipped the 5 apache ant zip again and everything worked 4 great.

The error message:

ANT_HOME is set 3 incorrectly or ant could not be located. Please 2 set ANT_HOME.

for not having an ANT_HOME/lib 1 directory was definitely misleading.

Score: 4

I was facing the same issue. But the problem 3 was that I had added ANT_HOME to user variables 2 in Windows.

I removed it and added ANT_HOME to system 1 variables. It works fine now.

Score: 3

My problem has solved in windows xp, Steps 2 are here (this is my setting change as per 1 your installation):

  1. Set ANT_HOME to E:\Software\apache-ant-1.8.4
  2. add in Path %ANT_HOME%\bin;
  3. open command prompt and run command ant (you will see out put from ant)
Score: 3

Try setting your ANT_HOME like below.it 1 worked for me


Score: 3

Adding manually from Windows sometimes does 2 not work...

To solve this, open command prompt 1 and type these commands;

C:\>set ANT_HOME=C:\apache-ant-1.9.2
C:\>set JAVA_HOME=C:\jdk1.7.0_25
C:\>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

... then test:

C:\>ant -version 
Apache Ant(TM) version 1.9.2 compiled on JULY 8 2013
Score: 3

Ok my problem was solved through this thread. I'll 1 just summarize what I did.

  1. Add the JAVA_HOME and ANT_HOME as system variables instead of user variables.
  2. Make sure that the JAVA_HOME is pointing towards your JDK directory and not the JRE directory. TOOLS.java is a part of JDK and not JRE.
Score: 2

setting ANT_HOME from cmd worked for me 1 somehow! C:>set ANT_HOME=C:\apache-ant-1.8.1

Score: 2

Close your command prompt after setting 2 your environment variables and open another 1 another one.

Score: 1

On Windows 7 you must run CMD as Adminitrator! When 2 you just click Start and type to search 1 box cmd then Java and ant both not recognized.

Score: 1

I had the same issue and I was able to fix 3 it by defining the %JAVA_HOME%\bin variable before defining 2 the %ANT_HOME%\bin in my Path.

CORRECT: Path %JAVA_HOME%\bin;%ANT_HOME%\bin;........

WRONG: Path 1 %ANT_HOME%\bin;%JAVA_HOME%\bin;.......

Score: 1

I had the same problem. If you check for 7 a bin folder in your apache-ant-1.9.4 folder, you may find 6 it doesn't exist.

This was the case for me, and 5 I fixed the issue by simply downloading 4 ant again and setting ANT_HOME,JAVA_HOME and PATH from cmd

All you 3 need to do is this; you don't need to waste 2 time trying to change and re-change your 1 env; just try downloading it again.

Score: 0

Somehow it appears to be very strange problem. Couple 11 of guesses:

1) I hope you've downloaded ANT 10 from here: http://apache.mirror.aussiehq.net.au//ant/binaries/apache-ant-1.8.2-bin.zip. If not, you can try that once.

2) I 9 hope there is no security related issues 8 that is preventing you to access ANT from 7 command window, just to double check, copy 6 the new ANT installation in some other directory, may 5 be D:\MyFolder etc..

3) Is Java - version running properly? Or are 4 you getting the similar kind of issue?

4) Also 3 Go inside $ANT_HOME\bin folder through command 2 prompt by typing cd C:\ant\bin and type 1 $ant.bat.. what error you get?

Score: 0

For me loading the *.zip version helped. It 1 seams it contains different data.

Score: 0

I ran into the same problem.

When you download 1 the zip file make sure you unblock the zip.


Score: 0

Looks like there is an issue with apache-ant-1.8.3\bin\ant.bat.

Just 3 comment the following lines in ant.bat and set 2 the ANT_HOME environment variable and it 1 should work.

if "%ANT_HOME%"=="" goto setDefaultAntHome

if not _%ANT_HOME:~-1%==_\ goto checkClasspath
set ANT_HOME=%ANT_HOME:~0,-1%
goto stripAntHome

rem %~dp0 is expanded pathname of the current script under NT
set ANT_HOME=%~dp0..
Score: 0

If you set through MyComputer-->Environment 6 variables it will work absolutely fine..

The 5 same thing was happening to me when I was 4 trying to do that through command prompt. It 3 was an issue... but I figured out the problem... problem 2 were the spaces


remove the spaces from the 1 above command it might work.

Score: 0

Sounds somewhat stupid, but try restarting 3 the computer if you haven't after the environment 2 variable additions. I wasted a couple of 1 hours not doing this.

Score: 0

Please try to set system variable of environment 5 variables to the following:

1)ANT_HOME :: your ant folder(e.g. C:\ant\...)
2)JAVA_HOME :: your JDK path
3)Path:Till bin path( e.g.C:\jdk\bin;C:\ant\bin;)with semicolon

I tryed setting 4 up ANT it was successful. Verify thro' command 3 promt by typing ... ant -version you should 2 get something like this: Apache Ant version 1 1.9.3 complied on December 10 2013

Score: 0

I had been facing the problem : here is 4 my fix that got the ant working.

  1. dowload 3 the proper file

    Go to


    and download the file "apache-ant-1.8.2-bin.zip"

  2. Set the 2 following variables in System Environment Variable:

     set ANT_HOME=C:\apache-ant-1.8.2
     set JAVA_HOME=C:\jdk1.7.0_25
     set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;

Thank 1 You.

Score: 0

In my case it was a silly mistake, when 6 you download the file I did not realize 5 was that the directory, apache-ant-1.9.3-bin and copy directly 4 to Program Files/apache-ant-1.9.3-bin. This gave me the error, I solved it 3 by copying the apache-ant-1.9.3 folder is 2 inside apache-ant-1.9.3-bin to Program Files/apache-ant-1.9.3 1 and perform the usual steps.

Score: 0

The trick is in avoiding spaces altogether!

Make 2 sure that you don't add any unneeded spaces 1 when adding to the PATH


Score: 0

Installing ANT gave me such hard time that 13 I decided to reply to this thread as soon 12 as I get it right.

I was getting the 'ANT_HOME 11 is set incorrectly...'

I tried everything 10 on this thread (almost) like %ANT_HOME%\bin 9 and swapping the JAVA_HOME and ANT_HOME 8 position on PATH variable, setting System 7 variables than User variable etc. Nothing 6 worked.

I downloaded the source distribution 5 and it had no bin folder in it. So I deleted 4 it, downloaded the binary version, unzipped 3 it and set the ANT_HOME to C:\apache-ant-1.7.0 2 and %ANT_HOME%\bin to PATH under User variable.

It 1 worked for me.

Score: 0

To set or install ANT just add the address 5 of your apache-ant into your PATH variables 4 next to your installed jdk file, as show 3 below

PATH Variables

C:\Program Files\Java\jdk1.8.0_45\bin;C:\Program 2 Files\apache-ant-1.9.6\bin

I hope this will 1 help you guys! enjoy

Score: 0

If getting error like ant_home is set incorrectly or ant could not be located. please set ant_home Then follow following 7 step which works for me.

1 . GO to computer 6 properties (windows+pause Break)--> advance 5 system setting

  1. System properties -->Advance---> environment 4 variable

  2. DELETE ANT_HOME from User Variable

  3. ADD 3 ANT_HOME in System variable and give the 2 path of your apache ant folder as shown 1 in figure.

Figure 1

  1. ADD OR copy and paste as it is %ANT_HOME%\bin in the last of you path as shown in figure.

enter image description here

  1. open cmd run ant -v that's all :)

enter image description here

Score: 0

I set up the environment variables for Java 3 and Ant correctly but it didnt work till 2 I restarted System. Set Environment variables 1 ANT_HOME, JAVA_HOME and restart system.

Score: 0

Fix all the environment variables to correct 6 location ANT_HOME, JAVA_HOME, PATH. Close the command prompt 5 and open a new command window. Try running 4 'ant' command. It worked for me.

To test 3 it : check the versions of JAVA and ANT.

C:> java -version
C:> ant -version

If 2 its showing versions then other commands 1 will also work.

Score: 0

Easy solution:

Use WinAnt installer for Windows. This installation 9 of Ant will automatically install Ant into 8 the C:\Program Files\WinAnt path by default. It also sets up your 7 ANT_HOME and PATH variables to point at the new installation.

Manuall installation:

  • Download a .zip binary distribution from the ANT Binary Page.
  • Save the .zip file to a temporary location on your hard-disk (such as the desktop)
  • Expand the contents the folder inside of the .zip file into a directory on your hard drive (i.e. C:\dev\ant)
  • Go to your "System" Control Panel. In Vista, click the "Change Settings" button under the "Computer name, domain, and workgroup" heading.
  • On the "Advanced" tab, click the button at the bottom labeled "Environment Variables"
  • At the top of the screen, add a new User variable. The name should be ANT_HOME, and the value should be the path your zip file was extracted to. (i.e. ANT_HOME = C:\dev\ant)
  • Add your java JDK Path to the user variables as well. The name should be JAVA_HOME and the value should be the path to the JDK software on your hard-drive. (i.e. JAVA_HOME = C:\Program Files\java\jdk1.8.0_xx)
  • If there is already a PATH variable, edit it and add to it. Otherwise, create one more variable named PATH, and add to it ;%ANT_HOME%\bin

After 6 installing Ant open the command prompt and 5 type ant -v which will print the ant version which 4 means you've successfully configured ant 3 in your windows machine. Some windows may 2 require a restart after setting the enviroment 1 variables.

Source: AntOnWindows

Score: 0

This is an update to other answers here: It 18 appears that ant comes with Netbeans 8.1, but 17 the developers of Netbeans have decided 16 to move ant out of the Netbeans core or 15 something. ( https://netbeans.org/bugzilla/show_bug.cgi?id=225753 ) see below for the new correct 14 path. For my current version of netbeans 13 8.1 this is what I had to do to get ant 12 to work from the command line: (Windows 11 10)

in system (not user) variables :

set JAVA_HOME to  C:\Program Files\Java\jdk1.8.0_73  (with your version number)

set ANT_HOME   to   C:\Program Files\NetBeans 8.1\extide\ant

add 10 to PATH in system variables : C:\Program Files\NetBeans 8.1\extide\ant\bin

so this has 9 'bin'added to ant home. (ant Home is one 8 dir higher)

Preferably set the path by browsing 7 to it using the environment var editor of 6 windows. It adds " " in the right 5 way.

( I was trying to install Jfreechart 4 which refers to using ant to install part 3 of it. That was supposed to make it easier..... yeah... after 2 figuering out and fixing the ant install 1 )

Score: 0

I had same trouble a while ago I think I 15 figured out the problem.

How : 1.Since I 14 Set ANT_HOME(C:\ant\ant-1.8.2) in Path correctly 13 I was confident about it. 2.I was planning 12 to do "ant setup" and "ant apply. I opened 11 path where I was planning to ant setup in 10 command prompt next I tried setenv.bat...

faced 9 ANT_HOME is set incorrectly or ant could 8 not be located. Please set ANT_HOME.

Setenv.bat 7 was setup something like this @echo off

set 6 JAVA_HOME=C:/Program Files (x86)/Java/jdk1.6.0_18 set 5 ANT_HOME=C:/Project/Setup_Binaries/JBoss_Ant_2012/ant-1.8.2 set 4 HOS_LIB_PATH=

Rather it should've been C:\ant\ant-1.8.2 3 which was changing my ANT_HOME.

I edited 2 setenv.bat to my ANT_HOME which I set in 1 PATH then it worked fine.

Score: 0

I was facing same problem but i resolved 4 it. in my case JAVA_HOME and ANT_HOME both 3 folder was at different-different location. I 2 kept both folder in "Program Files" and 1 my issue was resolved.

More Related questions