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.");
    }
  }
}
Home 
  Java Book 
    Essential Classes  

ProcessBuilder:
  1. ProcessBuilder class
  2. Create ProcessBuilder
  3. Get/set the working directory
  4. Get the environment variables
  5. Start a new process