开发者

ANT_HOME is set incorrectly or ant could not be located [duplicate]

This question already has answers here: Error installing Ant: ANT_HOME is set incorrectly 开发者_开发技巧 (31 answers) Closed 7 years ago.

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


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.


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.


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.


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


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


I've had the same problem, and this is how I resolved it:

Open your ANT directory and check that all the ANT files exist (like directories for bin,lib,etc...) I found my ANT directory was abnormal, just bin was there, the others like lib were missing. (I'm not sure what caused this)

If you have missing files/directories, unzip the apache-ant-1.9.4-bin.zip again, and make sure all the files exist.


If you are using Bamboo, make sure that the ant path in Bamboo setting is the same as your ANT_HOME.


I had the same problem and none of these solutions worked, so i simply deleted my ANT_HOME from enviroment variables, restarted my PC and I was all set to go


Check your existing PATH that may already included. Ant will not work if path is duplicated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜