Creating Native Processes from Java: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=


* http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html
* 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=
=Internal=


* [[Java#Subjects|Java]]
* [[Java#Subjects|Java]]
=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:
<pre>
public Process Runtime.exec(String[] cmdarray, String[] envp, File dir) throws Exception
</pre>

Latest revision as of 02:21, 23 February 2016

External

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