Create ProcessBuilder
ProcessBuilder(List<String> command)
- Creates a process builder with the specified operating system program and arguments.
ProcessBuilder(String... command)
- Creates a process builder with the specified operating system program and arguments.
Starts a process with a modified working directory and environment:
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");
Process p = pb.start();
} catch (Exception e) {
System.out.println("Error executing notepad.");
}
}
}