ANT_HOME is set incorrectly or ant could not be located

77,653

Solution 1

ANT_HOME might be set, but that doesn't mean the path to /bin is in your PATH so the OS can find it.

Add ANT_HOME/bin to your PATH and the OS will be able to find ant.bat.

Solution 2

Actually ANT_HOME should NOT be set where ant.bat is located.

It should be set to the ant.bat parent directory.

E.g.

C:\apache-ant-1.8.1 <-- ANT_HOME
  |
  bin <-- this is where ant.bat lives.

As duffymo correctly pointed out the ANT_HOME/bin still must be on your PATH.

Solution 3

Just sharing my experience, using cd %ANT_HOME% can point out errors in setting the variable correctly.

  1. ANT_HOME should point to the parent directory, not the bin.
  2. Path should include %ANT_HOME%\bin
  3. The ant.bat file under bin is editable, it can be altered to print the current value for ANT_HOME for troubleshooting.
  4. A system reboot is probably required for the system variables to get updated.

Solution 4

The ANT_HOME variable has to be a reference to the directory where the bin folder is found such as C:\Apps\apache-ant-1.8.4-bin\apache-ant-1.8.4\

The PATH reference can than be a reference to the ANT_HOME variable and the bin folder such as %ANT_HOME%\bin

example:

SET ANT_HOME=C:\Apps\apache-ant-1.8.4-bin\apache-ant-1.8.4\
SET PATH=%ANT_HOME%\bin

Solution 5

ANT_HOME should be set to the directory where ant is installed. e.g.

If your ant installation is located at: C:\tools\apache-ant

Your ANT_HOME should be set: set ANT_HOME=C:\tools\apache-ant at the System Environment settings and not User Environment Settings

Share:
77,653
SharpAffair
Author by

SharpAffair

Updated on January 06, 2020

Comments

  • SharpAffair
    SharpAffair over 4 years

    I'm trying to build a project in Ant, using BuildFile (build.xml). Although ANT_HOME environment variable clearly exists and is set to the path where "ant.bat" is located, it always displays this error message. How to configure Ant properly to compile builds in Windows?

    Thanks

  • Samuel
    Samuel almost 13 years
    if this doesn't work, go download the latest version. (not even sure what version i had...) +1
  • Roger_S
    Roger_S almost 11 years
    Note too that changing an environment variable like ANT_HOME won't be picked up by any command-prompt windows already open. If (like me) you had ANT_HOME pointing at the \bin directory where ant.bat lives, you also need to close your command-prompt window and open a new one.
  • Hoàng Long
    Hoàng Long over 9 years
    Thank you a lot about (3)! Adding a log sentence to the ant.bat, and checking the current ant version helps a lot!
  • Vijay Bhatt
    Vijay Bhatt over 8 years
    Follow link works for me..stackoverflow.com/questions/5607664/…
  • Deepak Shajan
    Deepak Shajan over 7 years
    thanks.This resolved the issue for me.I didn have the lib folder inside ant home.
  • Chagai Friedlander
    Chagai Friedlander almost 4 years
    @Roger_S just cost me a few hours...