Search code examples
unixpathcygwin

Cygwin: Unable to find Java path.


I am using cygwin on windows 7 env and it is unable to locate java, error message i get is that

ERROR: /cygdrive/c/Program
Files/Java/jdk1.6.0_22 does not exist!

wired path is if I do echo $JAVA_HOME then it shows me

$ echo $JAVA_HOME
/cygdrive/c/Program Files/Java/jdk1.6.0_22

not sure what is happening here, any suggestions?


Solution

  • The problem is that the pathname contains spaces. You need to escape the spaces as described here:

    http://www.cygwin.com/faq/faq.using.html#faq.using.filename-spaces

    Adding this line to your .bashrc should do it:

    export JAVA_HOME='/cygdrive/c/Program Files/Java/jdk1.6.0_22'
    

    Edit: You could try running this script which I found in this blog post:

    case "`uname`" in
      CYGWIN*) cygwin=true ;;
    
    esac
    
    # For Cygwin, switch paths to Windows format before running java
    if $cygwin; then
      JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
      CLASSPATH=`cygpath --windows --path "$CLASSPATH"`
    fi