JDK-8012609 : Runtime.getRuntime().exec(String) behaves differently on update 21
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7u21
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-04-18
  • Updated: 2013-04-18
  • Resolved: 2013-04-18
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_21 " 
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Tested only on Windows 7 64 bit

A DESCRIPTION OF THE PROBLEM :
I am running the below given program using Java 1.7.0_21-b11, 1.7.0_05-b06 and 1.6.0_34-b04 and the result is not same.

import java.io.File;

public class Test
{
public static void main(String a[]) throws Exception
{
String java_home = System.getProperty( " java.home " );
String lJavaWS = java_home + File.separator +  " bin "  + File.separator +  " javaws.exe " ;
System.out.println(lJavaWS);
Runtime.getRuntime().exec(lJavaWS);
}
}


For 1.7.0_21 I get an error,
Exception in thread  " main "  java.io.IOException: Cannot run program  " C:\Program " : CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
        at java.lang.Runtime.exec(Runtime.java:615)
        at java.lang.Runtime.exec(Runtime.java:448)
        at java.lang.Runtime.exec(Runtime.java:345)
        at Test.main(Test.java:16)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:288)
        at java.lang.ProcessImpl.start(ProcessImpl.java:133)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
        ... 4 more



For 1.7.0_05 and 1.6.0_34 I get Java Webstart usage dialog.

This is the bug and I had a look at the code but not able to figure out how this could happen when the code in Runtime.java looks same.

REGRESSION.  Last worked in version 6u45

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Please see the description.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Please see the description
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use overloaded Runtime.getRuntim().exec() methods and provide the program to be executed and its arguments in a string array.