3

enter image description here

Hi All,

I set ANT_HOME path but while trying to use ant -version i get the error "ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME"

Attached pic for reference.

Pls help.

pal
  • 1,202
  • 6
  • 17
  • 27

3 Answers3

9

You have ANT_HOME set 2 times :

  1. as User environment variable ANT_HOME=%ANT_HOME%\bin
  2. as System environment variable ANT_HOME=C:\ant-apache-1.9.3

Set ANT_HOME=C:\ant-apache-1.9.3 either as User variable OR as System variable but not both ! Afterwards put %ANT_HOME%\bin to your System Path variable

ANT_HOME has to be set to the rootfolder of your Ant installation => C:\ant-apache-1.9.3 in your case, it's similar to setting JAVA_HOME.
Including \bin is wrong !

Test your ant installation via cmd :

C:\Users\someuser>ant
Buildfile: build.xml does not exist!
Build failed

=> OK
For more details about your ant installation use :

C:\Users\someuser>ant -diagnostics
------- Ant diagnostics report -------
Apache Ant(TM) version 1.9.3 compiled on December 23 2013

-------------------------------------------
 Implementation Version
-------------------------------------------
core tasks     : 1.9.3 in file:/C:/ant193/lib/ant.jar

-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
ant.java.version: 1.7
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: C:\ant193\lib\ant.jar
...
Rebse
  • 10,307
  • 2
  • 38
  • 66
1

You have set the ANT_HOME, but you haven't added the ANT_HOME/bin directory to the PATH variable.

You need to modify your PATH variable in Environment variables like this

%ANT_HOME%\bin; Just add it and the end of your PATH variable value

I've just added the ANT bin directory to the existing PATH variable. Please follow this link

Keerthivasan
  • 12,760
  • 2
  • 32
  • 53
  • I already added ANT_HOME=C:\apache-ant-1.9.3\bin to the path variable but it gave me the same error. Where the SET PATH = %PATH%;%ANT_HOME%\bin; has to be added? system variables? – pal Feb 22 '14 at 07:22
  • Do you have `PATH` in your environment variables? Checout this [link](http://www.computerhope.com/issues/ch000549.htm) on how to set `PATH`. – Keerthivasan Feb 22 '14 at 07:24
  • follow link http://stackoverflow.com/questions/5607664/error-installing-ant-ant-home-is-set-incorrectly/32183652#32183652 – Vijay Bhatt Aug 24 '15 at 13:37
1

Delete the ANT_HOME path variable, the message is ACTUALLY saying it needs to use a project specific path. You are overriding it by setting ANT_HOME.

Shammoo
  • 1,084
  • 10
  • 22