How can I use Runtime.exec() to run MS-DOS commands without having MS-DOS shells popup each time?

John Zukowski

The following demonstrates executing a command without bringing up a popup.

import java.io.*;

public class Test {
  public static void main (String args[]) throws IOException {
    String[] command = { 
      "C:winntsystem32cmd.exe", "/y", "/c",
    Process p = Runtime.getRuntime().exec(command);
    InputStream is = p.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {

According to bug number 4244515 in Sun's Bug Parade (http://developer.java.sun.com/developer/bugParade/bugs/4244515.html), javaw doesn't always work without bringing up new window.