JDK-4247999 : Runtime.exec(net.exe) creates undesirable DOS prompt
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.1.8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-06-21
  • Updated: 1999-08-24
  • Resolved: 1999-08-24
Related Reports
Duplicate :  
Description

Name: krT82822			Date: 06/20/99


0. environment
6/20/99 kevin.ryan@eng -- from the command line, the "net start" command seems to write to normal stdout/err, and does not create a separate 
window.  However, even if you trap both stdout and stderr coming back from that process when exec()'d from Java, you get the extra DOS window
under JDK 1.1.8.  Not clear where this output is really going, or why this window is getting created.  FIling bug only FYI.
------------------------------------------

JDK 1.1.8 (tried 1.1.6, too)
Windows NT 4.0 Server + Service Pack 4 (Japanese version, though)

1.
Invoking Windows' net command makes another DOS prompt though I want it put
its result to the same window. I can't see the difference to other commmand
like cmd.exe.

The same code works well with Java2.

2. source for reproduction
------------------------------------------------------------------
import java.io.InputStream;

public class SimpleInvoker {
  public static void main(String[] args) throws Exception {
    Process p =
//    [all these work. callee's output is sent to the same DOS window]
//      Runtime.getRuntime().exec("c:\\winnt\\system32\\tree.com");
//      Runtime.getRuntime().exec("c:\\winnt\\system32\\ping.exe");
//      Runtime.getRuntime().exec("c:\\winnt\\system32\\cmd.exe /c dir");
//    [but this doesn't work in JDK1.1.6 and 1.1.8]
//    [works well with Java2. no popup window]
      Runtime.getRuntime().exec("c:\\winnt\\system32\\net.exe start");    
		InputStream in = p.getInputStream();
    int len;
    byte[] data = new byte[512];
    while( (len = in.read(data)) > 0){
      System.out.write(data, 0, len);
    }
  }
}
------------------------------------------------------------------

3. On JDK1.1.8, new popup DOS prompt is made but nothing come to the
   InputStream.

   On Java2, the result of the "net start" is shown on the same DOS
   prompt. Like below,

   -----------------------------------------------------------
   D:\JavaStorage\aki\application\callVBS>java SimpleInvoker
   These Windows NT services are started:
   
      Alerter
      Computer Browser
    (omit. all working NT services)
      Workstation
      World Wide Web Publishing Service

   The command completed successfully.
   -----------------------------------------------------------

5. 

C:\>\jdk1.1.8\bin\java.exe -version
java version "1.1.8"

C:\>\jdk1.1.8\bin\java.exe -fullversion
java full version "JDK1.1.8M"
(Review ID: 84574) 
======================================================================

Comments
EVALUATION This should be a spec issue. ###@###.### 1999-08-24
24-08-1999