ANT_HOME is set incorrectly or ant could not be located
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.
- ANT_HOME should point to the parent directory, not the bin.
- Path should include
%ANT_HOME%\bin
- The ant.bat file under bin is editable, it can be altered to print the current value for ANT_HOME for troubleshooting.
- 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
SharpAffair
Updated on January 06, 2020Comments
-
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 almost 13 yearsif this doesn't work, go download the latest version. (not even sure what version i had...) +1
-
Roger_S almost 11 yearsNote 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 over 9 yearsThank you a lot about (3)! Adding a log sentence to the ant.bat, and checking the current ant version helps a lot!
-
Vijay Bhatt over 8 yearsFollow link works for me..stackoverflow.com/questions/5607664/…
-
Deepak Shajan over 7 yearsthanks.This resolved the issue for me.I didn have the lib folder inside ant home.
-
Chagai Friedlander almost 4 years@Roger_S just cost me a few hours...