How can I use Runtime.exec() to run MS-DOS commands without having MS-DOS shells popup each time?
Created May 4, 2012
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", "dir"}; 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) { System.out.println(line); } } }However....
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.