简体   繁体   English

Ant Build无法识别JAVA_HOME

[英]Ant Build not able to recognize JAVA_HOME

I am getting following error while doing build using ANT: 使用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=

I understand that ANT is not able to point to JDK. 我知道ANT无法指向JDK。 I am starting ANT build via .bat file and there I am specifying following 我通过.bat文件启动ANT构建,并在那里指定以下内容

set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_30
set ANT_HOME=C:\Softwares\apache-ant-1.8.4

If add double quotes to JAVA_HOME value, I get following error: 如果为JAVA_HOME值添加双引号,我会收到以下错误:

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

Confusing part is if I change ANT_HOME to a previous version (1.6) it works fine. 令人困惑的部分是,如果我将ANT_HOME更改为以前的版本(1.6),它可以正常工作。

set ANT_HOME=C:\Softwares\Ant

This seems to be related to the 32bit JDK on a 64 bit Windows but I'm not sure about that. 这似乎与64位Windows上的32位JDK有关,但我不确定。

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%

Notice that progra~2 maps on my machine to the x86 program files directory. 请注意,我的机器上的progra~2映射到x86程序文件目录。 Might be different on yours so you need to check that. 你的可能会有所不同,所以你需要检查一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM