Start a new process
Process start()
- Starts a new process using the attributes of this process builder.
import java.io.File;
import java.util.Map;
public class Main{
public static void main(String args[]) {
try {
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
Map<String, String> env = pb.environment();
env.put("VAR1", "myValue");
env.remove("anotherValue");
pb.directory(new File("myDir"));
Process p = pb.start();
} catch (Exception e) {
System.out.println("Error executing notepad.");
}
}
}