java.lang · java.base · since Java 1.5
ProcessBuilder
public final class ProcessBuilderSpawn and wire OS processes: command, environment, working directory, and stream redirection — the safe, structured way to shell out.
Key methods
ProcessBuilder(String... command) | Argument list — no shell parsing, no injection. |
ProcessBuilder redirectErrorStream(boolean) | Merge stderr into stdout — avoids deadlocked pipes. |
Process start() | Launch. |
ProcessBuilder inheritIO() | Reuse the parent's console. |