While attempting to install Grails on Windows, I kept getting the following error when running grails:
C:\Users\praj> grails ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\Java\jdk1.6.0_17\
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
I had the JAVA_HOME variable set as a system environment variable (and it was pointing to an existing JDK installation). However, it turns out the problem was the trailing slash in my JAVA_HOME directory! Pretty obvious but anyway. So I changed it from:
C:\Program Files (x86)\Java\jdk1.6.0_17\ to C:\Program Files (x86)\Java\jdk1.6.0_17
Closed the current command prompt window and opened a new one, verified my JAVA_HOME:
C:\Users\praj> echo %JAVA_HOME% C:\Program Files (x86)\Java\jdk1.6.0_17
Note that when I quoted the path like this:
"C:\Program Files (x86)\Java\jdk1.6.0_17"
I kept getting the error Files were unexpected at this time so if you have the same problem, try dropping the quotes around the path.
wow, thanks man, you saved me a lot of trouble debugging this issue
Comment by michal — April 15, 2010 #