Runtime.exec

Runtime.exec

Class Overview | Class Members | This Package | All Packages

Syntax 1
public Process exec( String command ) throws IOException
Parameters
command
a specified system command.
Returns
a Process object for managing the subprocess.
Description
Executes the specified string command in a separate process.

The command argument is parsed into tokens and then executed as a command in a separate process. This method has exactly the same effect as exec(command, null).

Exceptions
SecurityException if the current thread cannot create a subprocess.
See Also
exec



Syntax 2
public Process exec( String command, String envp[] ) throws IOException
Parameters
command
a specified system command.
envp
array containing environment in format name=value
Returns
a Process object for managing the subprocess.
Description
Executes the specified string command in a separate process with the specified environment.

This method breaks the command string into tokens and creates a new array cmdarray containing the tokens; it then performs the call exec(cmdarray, envp).

Exceptions
SecurityException if the current thread cannot create a subprocess.
See Also
exec



Syntax 3
public Process exec( String cmdarray[] ) throws IOException
Parameters
cmdarray
array containing the command to call and its arguments.
Returns
a Process object for managing the subprocess.
Description
Executes the specified command and arguments in a separate process.

The command specified by the tokens in cmdarray is executed as a command in a separate process. This has exactly the same effect as exec(cmdarray, null).

Exceptions
SecurityException if the current thread cannot create a subprocess.
See Also
exec



Syntax 4
public Process exec( String cmdarray[], String envp[] ) throws IOException
Parameters
cmdarray
array containing the command to call and its arguments.
envp
array containing environment in format name=value.
Returns
a Process object for managing the subprocess.
Description
Executes the specified command and arguments in a separate process with the specified environment.

If there is a security manager, its checkExec method is called with the first component of the array cmdarray as its argument. This may result in a security exception.

Given an array of strings cmdarray, representing the tokens of a command line, and an array of strings envp, representing an "environment" that defines system properties, this method creates a new process in which to execute the specified command.

Exceptions
SecurityException if the current thread cannot create a subprocess.
See Also
SecurityException, checkExec