Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
630 views
in Technique[技术] by (71.8m points)

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,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I faced this problem too and I saw many posts but nothing really worked. There is a small trick that I did and things started working.

My JAVA_HOME was set to C:/Program Files/Java/jdk1.7.0_23. The problem was with Program Files directory and I was getting the same error.

In Windows there is a short name created for every directory with a space which is without a space. You can see it by running dir /X command on the command prompt. The Short name for Program Files was PROGRA~1.

In the Windows env variable through My Computer I changed the JAVA_HOME to C:/PROGR~1/Java/jdk1.7.0_23 and in hadoop-env.sh I changed JAVA_HOME to /cygdrv/c/PROGRA~1/Java/jdk1.7.0_23.

It worked fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...