Hi,
I want to execute many command line commands from my Java program. I have written the below code:
HashSet<String[]> commandSet = new HashSet<String[]>();
commandSet.add(new String[]{"cmd", "/C", command1});
...
...
commandSet.add(new String[]{"cmd", "/C", command100});
Process P;
Runtime rt = Runtime.getRuntime();
for(String[] command : commandSet){
P = rt.exec(command);
P.waitFor();
}
The problem is that it seems very inefficient to open a new command prompt for each command. Is it possible to execute all commands in the same command prompt?