Start a new process

ReturnMethodSummary
Processstart()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.");
    }
  }
}
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.