public class Runtime extends Object
Modifier and Type | Method and Description |
---|---|
void |
addShutdownHook(Thread hook) |
Process |
exec(String command)
Execute a new process using the single command line.
|
Process |
exec(String[] commands)
Execute a new process using individual command line arguments.
|
Process |
exec(String[] commands,
String[] envp)
Execute a new process using individual command line arguments and a supplied environment.
|
Process |
exec(String command,
String[] envp)
Execute a new process using the single command line and a supplied environment.
|
void |
exit(int exitCode) |
long |
freeMemory() |
void |
gc() |
static Runtime |
getRuntime() |
void |
halt(int exitCode) |
void |
load(String fullLibraryPathName)
Load a library name using the absolute path name.
|
void |
loadLibrary(String baseLibraryName)
Load a library name in a system dependant way (don't use an extension with the library name).
|
static void |
main(String[] args) |
boolean |
removeShutdownHook(Thread hook) |
void |
runFinalization() |
long |
totalMemory() |
void |
traceInstructions(boolean on) |
void |
traceMethodCalls(boolean on) |
public static Runtime getRuntime()
public void halt(int exitCode)
public void exit(int exitCode)
public void gc()
public long freeMemory()
public long totalMemory()
public void runFinalization()
public void load(String fullLibraryPathName) throws UnsatisfiedLinkError, SecurityException
libraryName
- The name and path of the library.UnsatisfiedLinkError
- If the library could not be loaded or is invalid.SecurityException
- If library loading is not allowed.public void loadLibrary(String baseLibraryName) throws UnsatisfiedLinkError, SecurityException
libraryName
- The name of the library.UnsatisfiedLinkError
- If the library could not be loaded or is invalid.SecurityException
- If library loading is not allowed.public void traceInstructions(boolean on)
public void traceMethodCalls(boolean on)
public Process exec(String command) throws IOException
command
- the command line to execute.IOException
- if the process could not be executed.public Process exec(String command, String[] envp) throws IOException
command
- the command line to execute.envp
- an array of strings, each element of which has environment variable settings in format name=value.
Under a native VM there are special environment variables that can be passed which will affect the way the process is executed. If the envp array contains ONLY these special variables, then these variables are utilized in the way described below, and the process will be executed as if envp is null - that is with the default behaviour.
The special values are: "*WorkingDirectory*" - which specifies the working directory for the process.
IOException
- if the process could not be executed.public Process exec(String[] commands) throws IOException
commands
- the command line arguments to run - with the first one being the
complete executable.IOException
- if the process could not be executed.public Process exec(String[] commands, String[] envp) throws IOException
commands
- the command line arguments to run - with the first one being the
complete executable.envp
- an array of strings, each element of which has environment variable settings in format name=value.
Under a native VM there are special environment variables that can be passed which will affect the way the process is executed. If the envp array contains ONLY these special variables, then these variables are utilized in the way described below, and the process will be executed as if envp is null - that is with the default behaviour.
The special values are: "*WorkingDirectory*" - which specifies the working directory for the process.
IOException
- if the process could not be executed.public void addShutdownHook(Thread hook)
public boolean removeShutdownHook(Thread hook)