JAVA: JAVA_HOME should point to a JDK not a JRE

Today when I was updating our JIRA instance I got the following error when I tried to start it:

The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

This made no sense since I had Java installed so I did the right thing and checked my JAVA_HOME environment variable:


C:\>echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.6.0_25

So… the JAVA_HOME variable was pointing in the right direction. The problem turned out to be that the path to the JDK folder contained spaces (in Program Files (x86)). So I went to C:\ and ran the command dir/x to see what the sort name for Program Files (x86) was:


C:\>dir/x
Volume in drive C is OS
Volume Serial Number is [none of you business]

Directory of C:\

...
21/08/2013 19:27 DIR eclipse
10/08/2012 17:09 DIR inetpub
22/03/2013 20:21 DIR NVIDIA
26/07/2012 09:33 DIR PerfLogs
23/07/2013 17:44 DIR PROGRA~1 Program Files
23/08/2013 09:14 DIR PROGRA~2 Program Files (x86)
08/07/2013 18:04 DIR Projects
14/07/2013 09:27 DIR Users
18/08/2013 17:38 DIR Windows
3 File(s) 14,643 bytes
12 Dir(s) 1,797,314,781,184 bytes free

The short hand version of Program Files (x86) was, as we can see, PROGRA~2. So I changed the environment variable to C:\PROGRA~2\Java\jdk1.6.0_25 by right clicking My Computer and selecting properties, then Advanced System Settings, Advanced tab, Environment Variables and locating it in the list (I’m using Windows 8 btw). That seems to have solved it.