Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8016468

LaunchingConnector fails to start java process if path contains spaces (Windows)

XMLWordPrintable

      FULL PRODUCT VERSION :
      java 7 u 21

      FULL OS VERSION :
      Windows 7

      A DESCRIPTION OF THE PROBLEM :
      LaunchingConnector fails if the path to java.exe contains blanks (for example C:\Program Files\Java\jre7\bin\java.exe):

      java.io.IOException: Cannot run program " C:\Program " : CreateProcess error=2, Das System kann die angegebene Datei nicht finden
      at java.lang.ProcessBuilder.start(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:162)
      at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:114)
      at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:217)


      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

      REGRESSION. Last worked in version 7u21

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.io.IOException: Cannot run program " C:\Program " : CreateProcess error=2, Das System kann die angegebene Datei nicht finden
      at java.lang.ProcessBuilder.start(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:162)
      at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:114)
      at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:217)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      // main programm

      import java.util.Map;

      import com.sun.jdi.Bootstrap;
      import com.sun.jdi.connect.Connector;
      import com.sun.jdi.connect.LaunchingConnector;

      public class Launch {

      public static void main(String[] a) throws Exception {
      LaunchingConnector connector = Bootstrap.virtualMachineManager()
      .defaultConnector();
      Map args = connector.defaultArguments();
      Connector.Argument main = (Connector.Argument) args.get( " main " );
      main.setValue( " test.Test " );
      Connector.Argument options = (Connector.Argument) args.get( " options " );
      options.setValue( " -classpath \ " . " + " \ " " );
      try {
      System.out.println(args);
      connector.launch(args);
      } catch (Exception e) {
      e.printStackTrace();
      return;
      }
      Thread.sleep(1000);
      }
      }

      // with this test class

      package test;

      import javax.swing.JFrame;

      public class Test {

      public Test() {
      JFrame frame = new JFrame( " hallo " );
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setBounds(2, 2, 300, 400);
      frame.setVisible(true);
      }
      public static void main(String[] args) {
      new Test();

      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Putting java.exe in another folder (for example C:\Programme\Java\jre7\bin\java.exe):

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: