Get the environment variables

ReturnMethodSummary
Map<String,String>environment()Returns a string map view of this process builder's 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");
      Map<String, String> env = pb.environment();
      env.put("VAR1", "myValue");
      env.remove("anotherValue");
      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.