Java Reference
In-Depth Information
The single argument forms of exec are equivalent to passing null for env ,
which means that the created process inherits the environment vari-
ables of its parent.
Environment variables are interpreted in a system-dependent way by
the child process's program. They can hold information such as the cur-
rent user name, the current working directory, search paths, or other
useful information that may be needed by a running program. The en-
vironment variables mechanism is supported because existing programs
on many different kinds of platforms understand them. You can get
the environment variables of the current runtime process from the Sys-
tem.getenv method, which returns an unmodifiable map of all the name/
value pairs. Individual values can be retrieved using the System.getenv
method which takes a string argument representing the name of the en-
vironment variable. The preferred way to communicate between differ-
ent virtual machine runtimes is with system properties (see page 663 ) .
However, this remains the only means of querying and subsequently
modifying the environment when executing a non-Java program.
There remain two further forms of exec that allow the initial working dir-
ectory of the child process to be specified:
public Process exec(String[] cmdArray, String[] env, File
dir)
throws IOException
public Process exec(String command, String[] env, File dir)
throws IOException
The child process is given an initial working directory as specified by the
path of dir . If dir is null , the child process inherits the current working
directory of the parentas specified by the system property user.dir . The
one- and two-argument forms of exec are equivalent to passing null for
dir .
 
Search WWH ::




Custom Search