Previously, we run external programs to use runtime.exec (..), now there is a new method.
Package maoxiang.examples.jdk15.lang;
Import java.util.map;
/ **
* @Author Mao Xiang
*
* /
Public class demoprocessBuilder {
Public static void main (String [] args) {
ProcessBuilder PB = New ProcessBuilder ("NOTEPAD.EXE");
Map env = pb.environment ();
Env.put ("var1", "myvalue");
Env.remove ("Othervar");
Env.put ("var2", env.get ("var1") "suffix");
System.out.println (pb.directory (). TOSTRING ());
Process p = pb.Start ();
}
}