Creating Native Processes from Java: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
=Overview= | =Overview= | ||
=ProcessBuilder.start()= | |||
<tt>ProcessBuilder.start()</tt> is the preferred way to start a process with a modified environment. | |||
=Runtime.exec()= | |||
<tt>Runtime.exec()</tt> 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 <tt>Process</tt> object for managing the subprocess. | |||
Canonical form: | Canonical form: |
Latest revision as of 02:21, 23 February 2016
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