Ant Build not able to recognize JAVA_HOME

2019-07-04 04:17发布

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=

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

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

Confusing part is if I change ANT_HOME to a previous version (1.6) it works fine.

set ANT_HOME=C:\Softwares\Ant

标签: java ant build
1条回答
戒情不戒烟
2楼-- · 2019-07-04 05:00

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%

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.

查看更多
登录 后发表回答