Build 1.0_r1(from source)

java.lang
Class Runtime

java.lang.Object
  extended by java.lang.Runtime

public class Runtime
extends Object

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.


Method Summary
 void addShutdownHook(Thread hook)
          Registers a new virtual-machine shutdown hook.
 int availableProcessors()
          Return the number of processors, always at least one.
 Process exec(String prog)
          Execute program in a separate platform process The new process inherits the environment of the caller.
 Process exec(String[] progArray)
          Execute progArray[0] in a separate platform process The new process inherits the environment of the caller.
 Process exec(String[] progArray, String[] envp)
          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)
          Execute progArray[0] in a separate platform process.
 Process exec(String prog, String[] envp)
          Execute prog in a separate platform process The new process uses the environment provided in envp
 Process exec(String prog, String[] envp, File directory)
          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()
          Returns 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.
 InputStream getLocalizedInputStream(InputStream stream)
          Deprecated. Use InputStreamReader
 OutputStream getLocalizedOutputStream(OutputStream stream)
          Deprecated. Use OutputStreamWriter
static Runtime getRuntime()
          Return the single Runtime instance
 void halt(int code)
          Causes the virtual machine to stop running, and the program to exit.
 void load(String pathName)
          Loads and links the library specified by the argument.
(package private)  void load(String filename, ClassLoader loader)
           
 void loadLibrary(String libName)
          Loads and links the library specified by the argument.
(package private)  void loadLibrary(String libname, ClassLoader loader)
           
 long maxMemory()
          Return the maximum memory that will be used by the virtual machine, or Long.MAX_VALUE.
 boolean removeShutdownHook(Thread hook)
          De-registers a previously-registered virtual-machine shutdown hook.
 void runFinalization()
          Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.
static void runFinalizersOnExit(boolean run)
          Deprecated. This method is unsafe.
 long totalMemory()
          Returns 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

exec

public Process exec(String[] progArray)
             throws 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.
Throws:
IOException - if the program cannot be executed
SecurityException - if the current SecurityManager disallows program execution
See Also:
SecurityManager.checkExec(java.lang.String)

exec

public Process exec(String[] progArray,
                    String[] envp)
             throws 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.
Throws:
IOException - if the program cannot be executed
SecurityException - if the current SecurityManager disallows program execution
See Also:
SecurityManager.checkExec(java.lang.String)

exec

public Process exec(String[] progArray,
                    String[] envp,
                    File directory)
             throws 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.
Throws:
IOException - if the program cannot be executed
SecurityException - if the current SecurityManager disallows program execution
See Also:
SecurityManager.checkExec(java.lang.String)

exec

public Process exec(String prog)
             throws 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
Throws:
IOException - if the program cannot be executed
SecurityException - if the current SecurityManager disallows program execution
See Also:
SecurityManager.checkExec(java.lang.String)

exec

public Process exec(String prog,
                    String[] envp)
             throws 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.
Throws:
IOException - if the program cannot be executed
SecurityException - if the current SecurityManager disallows program execution
See Also:
SecurityManager.checkExec(java.lang.String)

exec

public Process exec(String prog,
                    String[] envp,
                    File directory)
             throws 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
Throws:
IOException - if the program cannot be executed
SecurityException - if the current SecurityManager disallows program execution
See Also:
SecurityManager.checkExec(java.lang.String)

exit

public void 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.
Throws:
SecurityException - if the running thread is not allowed to cause the vm to exit.
See Also:
SecurityManager.checkExit(int)

freeMemory

public long freeMemory()
Returns the amount of free memory resources which are available to the running program.


gc

public void gc()
Indicates to the virtual machine that it would be a good time to collect available memory. Note that, this is a hint only.


getRuntime

public static Runtime getRuntime()
Return the single Runtime instance


load

public void 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
Throws:
UnsatisfiedLinkError - if the library could not be loaded
SecurityException - if the library was not allowed to be loaded

load

void load(String filename,
          ClassLoader loader)

loadLibrary

public void loadLibrary(String libName)
Loads and links the library specified by the argument.

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

loadLibrary

void loadLibrary(String libname,
                 ClassLoader loader)

runFinalization

public void runFinalization()
Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.


runFinalizersOnExit

@Deprecated
public static void runFinalizersOnExit(boolean run)
Deprecated. This method is unsafe.

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.

totalMemory

public long totalMemory()
Returns the total amount of memory resources which is available to (or in use by) the running program.


traceInstructions

public void 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.

traceMethodCalls

public void 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.

getLocalizedInputStream

@Deprecated
public InputStream getLocalizedInputStream(InputStream stream)
Deprecated. Use InputStreamReader


getLocalizedOutputStream

@Deprecated
public OutputStream getLocalizedOutputStream(OutputStream stream)
Deprecated. Use OutputStreamWriter


addShutdownHook

public void addShutdownHook(Thread hook)
Registers a new virtual-machine shutdown hook.

Parameters:
hook - the hook (a Thread) to register

removeShutdownHook

public boolean 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

halt

public void 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.
Throws:
SecurityException - if the running thread is not allowed to cause the vm to exit.
See Also:
SecurityManager.checkExit(int)

availableProcessors

public int availableProcessors()
Return the number of processors, always at least one.


maxMemory

public long maxMemory()
Return the maximum memory that will be used by the virtual machine, or Long.MAX_VALUE.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature