Create ProcessBuilder

ConstructorSummary
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.");
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.