Creating Native Processes from Java
Jump to navigation
Jump to search
External
- https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html
- When Runtime.exec() won't http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html
Internal
Overview
ProcessBuilder.start()
ProcessBuilder.start() is the preferred way to start a process with a modified environment.
Runtime.exec()
Runtime.exec() creates a new O/S process and executes the specified command and arguments in a separate process with the specified environment variables (each element of the String[] has a "name=value" format) and working directory.
If the environment variable array in null, the subprocess inherits the environment settings of the current Java process. If the working directory is null, the subprocess inherits the current working directory of the current process.
The call returns a new Process object for managing the subprocess.
Canonical form:
public Process Runtime.exec(String[] cmdarray, String[] envp, File dir) throws Exception