HHeLiBeXの日記 正道編

日々の記憶の記録とメモ‥

java.lang.ProcessBuilder クラス

Java 2 SE 5.0のJavaDocを何気なく眺めていてふと気になった。「確かこんなクラスはなかったよなぁ‥」と。確認してみたら、確かに「Since: 1.5」と書いてある。


This class is used to create operating system processes.
Each ProcessBuilder instance manages a collection of process attributes. The start() method creates a new Process instance with those attributes. The start() method can be invoked repeatedly from the same instance to create new subprocesses with identical or related attributes.
要するに、Runtimeクラスのexec()メソッドをより扱いやすくしたものということだろう。
Runtimeクラスのexec()メソッドJavaDocにはこんなことが書いてある。

ProcessBuilder.start() is now the preferred way to start a process with a modified environment.