Ant Build 无法识别 JAVA_HOME [英] Ant Build not able to recognize JAVA_HOME
问题描述
我在使用 ANT 进行构建时遇到以下错误:
I am getting following error while doing build using ANT:
rem bug ID 32069: resetting an undefined env variable changes the errorlevel.
if not "C:\Program Files (x86)\Java\jdk1.6.0_30\bin\java.exe" == "" set _JAVACMD=
if not "" == "" set ANT_CMD_LINE_ARGS=
我知道 ANT 无法指向 JDK.我正在通过 .bat
文件开始 ANT 构建,并在那里指定以下内容
I understand that ANT is not able to point to JDK. I am starting ANT build via .bat
file and there I am specifying following
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_30
set ANT_HOME=C:\Softwares\apache-ant-1.8.4
如果在 JAVA_HOME 值中添加双引号,则会出现以下错误:
If add double quotes to JAVA_HOME value, I get following error:
if exist "C:\Softwares\apache-ant-1.8.4\lib\ant.jar" goto checkJava
set _JAVACMD=
Files was unexpected at this time.
if ""C:\Program Files (x86)\Java\jdk1.6.0_30"" == "" goto noJavaHome
令人困惑的部分是,如果我将 ANT_HOME 更改为以前的版本 (1.6),它可以正常工作.
Confusing part is if I change ANT_HOME to a previous version (1.6) it works fine.
set ANT_HOME=C:\Softwares\Ant
推荐答案
这似乎与 64 位 Windows 上的 32 位 JDK 有关,但我不确定.
This seems to be related to the 32bit JDK on a 64 bit Windows but I'm not sure about that.
对我有用的是使用旧的 ~ 技巧,它显然仍然有效.所以在你的情况下它可能应该是:
What worked for me was using the old ~ trick which apparently still works. So in your case it should probably be:
set JAVA_HOME=C:\Progra~2\Java\jdk1.6.0_30
set PATH=C:\Progra~2\Java\jdk1.6.0_30\bin;%PATH%
注意 progra~2 在我的机器上映射到 x86 程序文件目录.你的可能会有所不同,所以你需要检查一下.
Notice that progra~2 maps on my machine to the x86 program files directory. Might be different on yours so you need to check that.
这篇关于Ant Build 无法识别 JAVA_HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!