// using ProcessBuilder to spawn an process ProcessBuilder pb = new ProcessBuilder( "dolunch.exe", "firstarg", "secondarg" ); Map<String, String> env = pb.environment(); // insert set FRUIT=strawberry into environment just for our children env.put( "FRUIT", "strawberry" ); // remove set LIVERCOURSE=YES from environment just for our children env.remove( "LIVERCOURSE" ); // modify set WINE=pinot to WINE=pinot blanc env.put( "WINE", env.get("WINE") + " blanc" ); // set up the working directory. // Note the method is called "directory" not "setDirectory" pb.directory( new File( "/lunchDir" ) ); // merge child's error and normal output streams. // Note it is not called setRedirectErrorStream. pb.redirectErrorStream( true ); Process p = pb.start(); // From here on it, it behaves just like exec, since you have the // exact same Process object. // ... // You can reuse the ProcessBuilder objects. // They retain their initialisation. Process sister = pb.Start();