locked
Java recognizes JAVA_HOME where spaces are included in the path on some windows machines, but other Windows machines throws Exception RRS feed

  • General discussion

  • Hi All, 

    Hopefully, I"ve put this topic in the right forum....I have a very unique problem that I've been banging my head on, and after much research and attempted fixes, I just cannot seem to figure it out.   Hopefully someone can help me out here.   

    The scenario:

    I'm trying to run a java program (executing a jar file from the command line as Administrator), and have ensured that my JAVA_HOME has been properly set.   My exact JAVA_HOME is C:\Program Files\Java\jdk1.7.0_21.

    I have verified that there are no typos within the environment variable settings.   Now the strange thing is, for some Windows machines (Windows 7) java is able to execute, and has no problem reading JAVA_HOME. 

    However, on some other Windows machines, I encounter the following exception:

    java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The
     system cannot find the file specified
            at java.lang.ProcessBuilder.start(Unknown Source)
            at java.lang.Runtime.exec(Unknown Source)
            at java.lang.Runtime.exec(Unknown Source)
            at java.lang.Runtime.exec(Unknown Source)
            at com.sightline.edm.pack.DCSHelloPanel.checkJreVersion(DCSHelloPanel.ja
    va:55)
            at com.sightline.edm.pack.DCSHelloPanel.<init>(DCSHelloPanel.java:45)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at com.izforge.izpack.installer.InstallerFrame.loadPanels(Unknown Source
    )
            at com.izforge.izpack.installer.InstallerFrame.<init>(Unknown Source)
            at com.izforge.izpack.installer.GUIInstaller.loadGUI(Unknown Source)
            at com.izforge.izpack.installer.GUIInstaller.access$100(Unknown Source)
            at com.izforge.izpack.installer.GUIInstaller$2.run(Unknown Source)
            at java.awt.event.InvocationEvent.dispatch(Unknown Source)
            at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
            at java.awt.EventQueue.access$200(Unknown Source)
            at java.awt.EventQueue$3.run(Unknown Source)
            at java.awt.EventQueue$3.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
    ce)
            at java.awt.EventQueue.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
    e file specified
            at java.lang.ProcessImpl.create(Native Method)
            at java.lang.ProcessImpl.<init>(Unknown Source)
            at java.lang.ProcessImpl.start(Unknown Source)
            ... 29 more

    Researched indicated that java doesn't like the space between Program Files within the JAVA_HOME path and fails to execute.  I have found a workaround for this (use Progra~1 or Progra~2 in the path) but my question is,  how are some windows 7 machines able to run java fine with a space (Program Files) being in JAVA_HOME path, where as some machines cannot and spits out the exception??  Another interesting fact is that I encountered this exception on a machine that USED to work with having a space (Program Files) in the JAVA_HOME path, but now does not!  

    Could this be due to a Windows update that might have not allowed spaces to be in Environment variables anymore?  

    Any assistance or help would be much appreciated.  Thanks again in advance. 

    -JP



    • Edited by fluxviolin Thursday, June 6, 2013 8:26 PM
    • Changed type Cloud_TS Wednesday, June 19, 2013 7:17 AM redirection
    Thursday, June 6, 2013 8:07 PM

All replies