export JAVA_HOME with spaces in Cygwin

后端 未结 7 939
失恋的感觉
失恋的感觉 2020-12-19 01:47

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

7条回答
  •  Happy的楠姐
    2020-12-19 02:36

    To avoid using the tedious Windows environment variables, and also use the actual path string copied from Windows explorer, I suggest adding the following to your startup script:

                 TMP=`cygpath -sw "C:\Program Files\Java\jdk1.8.0_31"`
    export JAVA_HOME=`cygpath -u $TMP`
    

    The first cygpath invocation obtains a short, windows path; the second converts it to unix format, which works fine in cygwin.

    This will also now work fine:

    $ cd $JAVA_HOME
    

提交回复
热议问题