Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Java path on Windows for Ant

Tags:

ant

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?

like image 974
Graham Seed Avatar asked Jan 19 '13 14:01

Graham Seed


People also ask

How do I change the path of an ant in Windows 10?

Choose Start -> Control Panel, and double-click the System icon. Click the Advanced tab, and then click the Environment Variables button. Under System Variables, select New to create the ANT_HOME environment variable.

Where is my Java home path in Windows?

Open a Command Prompt window (Win⊞ + R, type cmd, hit Enter). Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn't, your JAVA_HOME variable was not set correctly.


3 Answers

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
like image 127
Jayan Avatar answered Nov 16 '22 01:11

Jayan


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)
like image 29
Will Avatar answered Nov 16 '22 01:11

Will


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.

like image 32
user3165969 Avatar answered Nov 16 '22 03:11

user3165969