Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

export JAVA_HOME with spaces in Cygwin

I'm trying to set my JAVA_HOME in Cygwin with this command:

export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.7.0_10"

But when I do cd $JAVA_HOME, I'd get this error:

$ cd $JAVA_HOME
-bash: cd: /cygdrive/c/Program: No such file or directory

I tried quoting, and escaping the space (ie., \), but none worked. Any idea what else would?

Thanks,

like image 964
user1508893 Avatar asked Jan 28 '13 17:01

user1508893


2 Answers

You set JAVA_HOME correctly. Now let's cd correctly too.

cd "$JAVA_HOME"
like image 89
Anton Kovalenko Avatar answered Oct 13 '22 11:10

Anton Kovalenko


Try using the DOS subst command to take the spaces of the JAVA_HOME path name. Assuming drive J; is not mounted or otherwise used.

In a DOS shell

subst j: "C:/Program Files/Java/jdk1.7.0_45"

J: is now an abbreviation for C:/Program Files/Java/jdk1.7.0_45

You can now cd to J:

now run Cygwin and

export JAVA_HOME="J:"
like image 27
Tim Child Avatar answered Oct 13 '22 09:10

Tim Child