Android
java.lang
public class

java.lang.Runtime

java.lang.Object
java.lang.Runtime

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.

Summary

Public Methods

          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[] 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)
Execute program in a separate platform process The new process inherits the environment of the caller.
          Process  exec(String prog, String[] envp, File directory)
Execute prog in a separate platform process The new process uses the environment provided in envp
          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
          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)
This method is deprecated. Use InputStreamReader
          OutputStream  getLocalizedOutputStream(OutputStream stream)
This method is 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.
          void  loadLibrary(String libName)
Loads and links the library specified by the argument.
          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)
This method is 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

Details

Public Methods

public void addShutdownHook(Thread hook)

Registers a new virtual-machine shutdown hook.

Parameters

hook the hook (a Thread) to register

public int availableProcessors()

Return the number of processors, always at least one.

public Process exec(String[] progArray, String[] envp, File directory)

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

public Process exec(String prog, String[] envp)

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

public Process exec(String prog)

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

public Process exec(String prog, String[] envp, File directory)

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

public Process exec(String[] progArray)

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

public Process exec(String[] progArray, String[] envp)

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

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

public long freeMemory()

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

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.

public InputStream getLocalizedInputStream(InputStream stream)

This method is deprecated. Use InputStreamReader

public OutputStream getLocalizedOutputStream(OutputStream stream)

This method is deprecated. Use OutputStreamWriter

public static Runtime getRuntime()

Return the single Runtime instance

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

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

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

public long maxMemory()

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

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

public void runFinalization()

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

public static void runFinalizersOnExit(boolean run)

This method is 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.

public long totalMemory()

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

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.

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.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56