java.lang.Runtime Class Reference

List of all members.


Detailed Description

This class, with the exception of the exec() APIs, must be implemented by the VM vendor.

The exec() APIs must first do any required security checks, and then call org.apache.harmony.luni.internal.process.SystemProcess.create(). The Runtime interface.

Public Member Functions

Process exec (String[] progArray) throws java.io.IOException
 Execute progArray[0] in a separate platform process The new process inherits the environment of the caller.
Process exec (String[] progArray, String[] envp) throws java.io.IOException
 Execute progArray[0] in a separate platform process The new process uses the environment provided in envp.
Process exec (String[] progArray, String[] envp, File directory) throws java.io.IOException
 Execute progArray[0] in a separate platform process.
Process exec (String prog) throws java.io.IOException
 Execute program in a separate platform process The new process inherits the environment of the caller.
Process exec (String prog, String[] envp) throws java.io.IOException
 Execute prog in a separate platform process The new process uses the environment provided in envp.
Process exec (String prog, String[] envp, File directory) throws java.io.IOException
 Execute prog in a separate platform process The new process uses the environment provided in envp.
void exit (int code)
 Causes the virtual machine to stop running, and the program to exit.
long freeMemory ()
 Answers the amount of free memory resources which are available to the running program.
void gc ()
 Indicates to the virtual machine that it would be a good time to collect available memory.
void load (String pathName)
 Loads and links the library specified by the argument.
void loadLibrary (String libName)
 Loads and links the library specified by the argument.
void runFinalization ()
 Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.
long totalMemory ()
 Answers the total amount of memory resources which is available to (or in use by) the running program.
void traceInstructions (boolean enable)
 Turns the output of debug information for instructions on or off.
void traceMethodCalls (boolean enable)
 Turns the output of debug information for methods on or off.
InputStream getLocalizedInputStream (InputStream stream)
OutputStream getLocalizedOutputStream (OutputStream stream)
void addShutdownHook (Thread hook)
 Registers a new virtual-machine shutdown hook.
boolean removeShutdownHook (Thread hook)
 De-registers a previously-registered virtual-machine shutdown hook.
void halt (int code)
 Causes the virtual machine to stop running, and the program to exit.
int availableProcessors ()
 Return the number of processors, always at least one.
long maxMemory ()
 Return the maximum memory that will be used by the virtual machine, or Long.MAX_VALUE.

Static Public Member Functions

static Runtime getRuntime ()
 Return the single Runtime instance.
static void runFinalizersOnExit (boolean run)
 Ensure that, when the virtual machine is about to exit, all objects are finalized.

Private Member Functions

 Runtime ()
 Prevent this class from being instantiated.


Constructor & Destructor Documentation

java.lang.Runtime.Runtime (  )  [private]

Prevent this class from being instantiated.


Member Function Documentation

Process java.lang.Runtime.exec ( String[]  progArray  )  throws java.io.IOException

Execute progArray[0] in a separate platform process The new process inherits the environment of the caller.

Parameters:
progArray the array containing the program to execute as well as any arguments to the program.
Exceptions:
java.io.IOException if the program cannot be executed
SecurityException if the current SecurityManager disallows program execution
See also:
SecurityManager.checkExec

Process java.lang.Runtime.exec ( String[]  progArray,
String[]  envp 
) throws java.io.IOException

Execute progArray[0] in a separate platform process The new process uses the environment provided in envp.

Parameters:
progArray the array containing the program to execute a well as any arguments to the program.
envp the array containing the environment to start the new process in.
Exceptions:
java.io.IOException if the program cannot be executed
SecurityException if the current SecurityManager disallows program execution
See also:
SecurityManager.checkExec

Process java.lang.Runtime.exec ( String[]  progArray,
String[]  envp,
File  directory 
) throws java.io.IOException

Execute progArray[0] in a separate platform process.

The new process uses the environment provided in envp

Parameters:
progArray the array containing the program to execute a well as any arguments to the program.
envp the array containing the environment to start the new process in.
directory the directory in which to execute progArray[0]. If null, execute in same directory as parent process.
Exceptions:
java.io.IOException if the program cannot be executed
SecurityException if the current SecurityManager disallows program execution
See also:
SecurityManager.checkExec

Process java.lang.Runtime.exec ( String  prog  )  throws java.io.IOException

Execute program in a separate platform process The new process inherits the environment of the caller.

Parameters:
prog the name of the program to execute
Exceptions:
java.io.IOException if the program cannot be executed
SecurityException if the current SecurityManager disallows program execution
See also:
SecurityManager.checkExec

Process java.lang.Runtime.exec ( String  prog,
String[]  envp 
) throws java.io.IOException

Execute prog in a separate platform process The new process uses the environment provided in envp.

Parameters:
prog the name of the program to execute
envp the array containing the environment to start the new process in.
Exceptions:
java.io.IOException if the program cannot be executed
SecurityException if the current SecurityManager disallows program execution
See also:
SecurityManager.checkExec

Process java.lang.Runtime.exec ( String  prog,
String[]  envp,
File  directory 
) throws java.io.IOException

Execute prog in a separate platform process The new process uses the environment provided in envp.

Parameters:
prog the name of the program to execute
envp the array containing the environment to start the new process in.
directory the initial directory for the subprocess, or null to use the directory of the current process
Exceptions:
java.io.IOException if the program cannot be executed
SecurityException if the current SecurityManager disallows program execution
See also:
SecurityManager.checkExec

void java.lang.Runtime.exit ( int  code  ) 

Causes the virtual machine to stop running, and the program to exit.

If runFinalizersOnExit(true) has been invoked, then all finalizers will be run first.

Parameters:
code the return code.
Exceptions:
SecurityException if the running thread is not allowed to cause the vm to exit.
See also:
SecurityManager.checkExit

long java.lang.Runtime.freeMemory (  ) 

Answers the amount of free memory resources which are available to the running program.

void java.lang.Runtime.gc (  ) 

Indicates to the virtual machine that it would be a good time to collect available memory.

Note that, this is a hint only.

static Runtime java.lang.Runtime.getRuntime (  )  [static]

Return the single Runtime instance.

void java.lang.Runtime.load ( String  pathName  ) 

Loads and links the library specified by the argument.

Parameters:
pathName the absolute (ie: platform dependent) path to the library to load
Exceptions:
UnsatisfiedLinkError if the library could not be loaded
SecurityException if the library was not allowed to be loaded

void java.lang.Runtime.loadLibrary ( String  libName  ) 

Loads and links the library specified by the argument.

Parameters:
libName the name of the library to load
Exceptions:
UnsatisfiedLinkError if the library could not be loaded
SecurityException if the library was not allowed to be loaded

void java.lang.Runtime.runFinalization (  ) 

Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.

static void java.lang.Runtime.runFinalizersOnExit ( boolean  run  )  [static]

Ensure that, when the virtual machine is about to exit, all objects are finalized.

Note that all finalization which occurs when the system is exiting is performed after all running threads have been terminated.

Parameters:
run true means finalize all on exit.
Deprecated:
This method is unsafe.

long java.lang.Runtime.totalMemory (  ) 

Answers the total amount of memory resources which is available to (or in use by) the running program.

void java.lang.Runtime.traceInstructions ( boolean  enable  ) 

Turns the output of debug information for instructions on or off.

Parameters:
enable if true, turn trace on. false turns trace off.

void java.lang.Runtime.traceMethodCalls ( boolean  enable  ) 

Turns the output of debug information for methods on or off.

Parameters:
enable if true, turn trace on. false turns trace off.

InputStream java.lang.Runtime.getLocalizedInputStream ( InputStream  stream  ) 

Deprecated:
Use InputStreamReader

OutputStream java.lang.Runtime.getLocalizedOutputStream ( OutputStream  stream  ) 

Deprecated:
Use OutputStreamWriter

void java.lang.Runtime.addShutdownHook ( Thread  hook  ) 

Registers a new virtual-machine shutdown hook.

Parameters:
hook the hook (a Thread) to register

boolean java.lang.Runtime.removeShutdownHook ( Thread  hook  ) 

De-registers a previously-registered virtual-machine shutdown hook.

Parameters:
hook the hook (a Thread) to de-register
Returns:
true if the hook could be de-registered

void java.lang.Runtime.halt ( int  code  ) 

Causes the virtual machine to stop running, and the program to exit.

Finalizers will not be run first. Shutdown hooks will not be run.

Parameters:
code the return code.
Exceptions:
SecurityException if the running thread is not allowed to cause the vm to exit.
See also:
SecurityManager.checkExit

int java.lang.Runtime.availableProcessors (  ) 

Return the number of processors, always at least one.

long java.lang.Runtime.maxMemory (  ) 

Return the maximum memory that will be used by the virtual machine, or Long.MAX_VALUE.


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:47 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.