FileDocCategorySizeDatePackage
ProcessBuilderDemo.javaAPI DocExample914Thu Mar 25 20:48:36 GMT 2004None

ProcessBuilderDemo

public class ProcessBuilderDemo extends Object
ProcessBuilderDemo shows how to execute an external program (in this case the MS-Windows notepad program).

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		
		List<String> command = new ArrayList<String>();
		command.add("notepad");
		command.add("foo.txt");
		ProcessBuilder builder = new ProcessBuilder(command);
		Map<String, String> environ = builder.environment();
		environ.put("PATH", "/windows;/windows/system32;/winnt");
		builder.directory(
			new File(System.getProperty("user.home")));

		final Process godot = builder.start();
		
		Debug.println("exec", "Waiting for Godot");
		godot.waitFor();

		System.out.println("Program terminated!");
		return;