Setting Java path on Windows for Ant

谁都会走 提交于 2019-12-23 07:54:26

问题


Just downloaded the latest version of Ant and installed at:

C:\apache-ant-1.8.4

I added the following to the Env Path variable:

...;C:\apache-ant-1.8.4\bin

When I open a terminal window and type:

ant -version

I get:

Files\Java\jdk1.7.0_07"" was unexpected at this time.

In System variables I have the variable JAVA_HOME set to:

"C:\Program Files\Java\jdk1.7.0_07"

so it appears that "ant -version" is struggling to read the space in JAVA_HOME even though it is in quotes.

I see an alternative post on this topic:

Ant and Eclipse

but it doesn't tackle this specific point.

Has anyone else encountered this problem and know the answer?


回答1:


My guess is current definition of JAVA_HOME has unwanted double quotes. Show output of set JAVA_HOME on command window. It should not have any double quotes.

Please start command prompt. Set the JAVA_HOME again

set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07



回答2:


Hmmm, it should be fine with quotes. Could be something else in your path. If all else fails you could revert to dos 8.3 notation.

dir /x

Which gives

13/01/2013  03:57 PM    <DIR>          PROGRA~1     Program Files
13/01/2013  03:57 PM    <DIR>          PROGRA~2     Program Files (x86)



回答3:


In case anyone else is still encountering this problem, I am on Windows 7 and was experiencing the same. I was using the GUI provided by right-clicking the "computer" icon to attempt to set the JAVA_HOME path to the relevant program files folder (C:\Program Files (x86)\Java\jdk1.7.0_45). This will not work! The GUI doesn't accept spaces in paths. Command line however, does. Use set JAVA_HOME= C:\Program Files... to get it working, filling out the rest of the path with the location of your jdk installation.



来源:https://stackoverflow.com/questions/14415442/setting-java-path-on-windows-for-ant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!