Java ANT_HOME 设置不正确或找不到蚂蚁

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3382583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 22:45:18  来源:igfitidea点击:

ANT_HOME is set incorrectly or ant could not be located

javaantbuildcompilation

提问by SharpAffair

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?

我正在尝试使用 BuildFile (build.xml) 在 Ant 中构建一个项目。虽然ANT_HOME环境变量明明存在并且设置为“ant.bat”所在的路径,但是总是显示这个错误信息。如何正确配置 Ant 以在 Windows 中编译构建?

Thanks

谢谢

采纳答案by duffymo

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

ANT_HOME 可能已设置,但这并不意味着 /bin 的路径在您的 PATH 中,因此操作系统可以找到它。

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

将 ANT_HOME/bin 添加到您的 PATH 中,操作系统将能够找到ant.bat.

回答by Alexander Pogrebnyak

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

实际上 ANT_HOME 不应该设置在 ant.bat 所在的位置。

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

它应该设置为 ant.bat 父目录。

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.

正如 duffymo 正确指出 ANT_HOME/bin 仍然必须在您的 PATH 上。

回答by naikus

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

ANT_HOME 应设置为安装 ant 的目录。例如

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

如果您的 ant 安装位于:C:\tools\apache-ant

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

您的 ANT_HOME 应该设置为:set ANT_HOME=C:\tools\apache-ant在系统环境设置而不是用户环境设置中

回答by msnewbit14

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

只是分享我的经验,使用cd %ANT_HOME%可以指出正确设置变量的错误。

  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.
  1. ANT_HOME 应该指向父目录,而不是 bin。
  2. 路径应包括 %ANT_HOME%\bin
  3. bin 下的 ant.bat 文件是可编辑的,可以更改它以打印 ANT_HOME 的当前值以进行故障排除。
  4. 系统变量可能需要重新启动才能更新。

回答by victor h damian chicon

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

ANT_HOME变量必须是对bin文件夹所在目录的引用,例如C:\Apps\apache-ant-1.8.4-bin\apache-ant-1.8.4\

The PATHreference can than be a reference to the ANT_HOMEvariable and the binfolder such as %ANT_HOME%\bin

所述PATH参考值可以是比所述参考ANT_HOME变量和bin如夹%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

回答by Gupta

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

如果您使用的是 Bamboo,请确保 Bamboo 设置中的蚂蚁路径与您的 ANT_HOME 相同。

回答by Luke

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)

打开你的 ANT 目录并检查所有 ANT 文件是否存在(如 bin、lib 等目录)我发现我的 ANT 目录异常,只有 bin 在那里,其他的像 lib 都不见了。(我不确定是什么原因造成的)

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

如果您缺少文件/目录,请再次解压缩 apache-ant-1.9.4-bin.zip,并确保所有文件都存在。

回答by Sagar Devanga

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

我遇到了同样的问题,但这些解决方案都没有奏效,所以我只是从环境变量中删除了我的 ANT_HOME,重新启动了我的电脑,我就准备好了

回答by james

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

检查可能已包含的现有PATH。如果路径重复,Ant 将无法工作。