JAVA_HOME fails on spaces and quotation marks with SET command

Posted on 2014-08-21
Last Modified: 2014-08-22
On WIndows 2008...

From a Command prompt...

I performed the following:

SET JAVA_HOME="c:\program files (x86)\Java60\jre"

Open in new window

Now I can do the following:

echo %JAVA_HOME%
"c:\program files (x86)\Java60\jre"

Open in new window

So now I try an installation procedure of Shibboleth, and later in the install, the install crashed on this line:

  set JAVACMD="%JAVA_HOME%\bin\java.exe"

Open in new window

The command prompt now breaks out of the .bat file and reports the following:

\Java60\jre"\bin\java.exe" was unexpected at this time.
  set JAVACMD=""c:\program files (x86)\Java60\jre"\bin\java.exe"

Open in new window

There are two spaces in the JAVA_HOME "Program Files (", so I have to set the JAAVA_HOME with quotation marks, as follows:

SET JAVA_HOME="c:\program files (x86)\Java60\jre"

Open in new window

... and either the spaces or the quotation marks are causing an issue

How can I fix this?

Question by:Anthony Lucia
    LVL 26

    Expert Comment

    Much the simplest fix (if you can) is to reinstall Java so it has no space in the path.  Personally I always put it in:


    If not you will keep running into these sorts of problems.

    LVL 20

    Accepted Solution

    Try the following without quotation:

    SET JAVA_HOME=C:\progra~2\Java60\jre

    Open in new window

    LVL 61

    Expert Comment

    You dont have to set JAVA_HOME if you install official java package

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now