import java.io.IOException; import java.util.Map; public class EnvSet { public static void main(String[] args) { ProcessBuilder proc = new ProcessBuilder(); // Configure to start a new command shell // with given command line arguments passed: proc.command("cmd", "/c", "start"); // Modify environment to contain new variables: Map env = proc.environment(); env.put("MON", "Meatloaf"); env.put("TUES", "Taco"); env.put("WED", "Wienerschnitzel"); // Run the command, or report an error if it failed try { proc.start(); } catch (IOException ex) { System.err.println("Error starting cmd:" + ex); } } }