java.lang
Class Runtime

java.lang.Object
  |
  +--java.lang.Runtime

public class Runtime
extends Object


Method Summary
 Process exec(String command)
          Executes the system command specified in the parameter.
 Process exec(String[] cmdarray)
          Executes the system command specified by cmdarray[0] with arguments specified by the strings in the rest of the array.
 Process exec(String[] cmdarray, String[] envp)
          Executes the system command specified by cmdarray[0] with arguments specified by the strings in the rest of the array.
 Process exec(String command, String[] envp)
          Executes the system command specified in the parameter.
 void exit(int status)
          Exits the virtual machine with an exit code.
 long freeMemory()
          Returns the number of free bytes in system memory.
 void gc()
          Runs the garbage collector.
 InputStream getLocalizedInputStream(InputStream in)
          Localize an input stream.
 OutputStream getLocalizedOutputStream(OutputStream out)
          Localize an output stream.
static Runtime getRuntime()
          Returns the runtime.
 void load(String filename)
          Loads a dynamic library, given a complete path name.
 void loadLibrary(String libname)
          Loads a dynamic library with the specified library name.
 void runFinalization()
          Runs the finalization methods of any objects pending finalization.
 long totalMemory()
          Returns the total number of bytes in system memory.
 void traceInstructions(boolean on)
          Enables/Disables tracing of instructions.
 void traceMethodCalls(boolean on)
          Enables/Disables tracing of method calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRuntime

public static Runtime getRuntime()
Returns the runtime.


exit

public void exit(int status)
Exits the virtual machine with an exit code. This method does not return, use with caution.

Parameters:
status - exit status, 0 if successful, other values indicate various error types.

exec

public Process exec(String command)
             throws IOException
Executes the system command specified in the parameter. Returns a Process which has methods for optaining the stdin, stdout, and stderr of the subprocess. This method fails if executed by untrusted code.

Parameters:
command - a specified system command
Returns:
an instance of class Process
IOException

exec

public Process exec(String command,
                    String[] envp)
             throws IOException
Executes the system command specified in the parameter. Returns a Process which has methods for optaining the stdin, stdout, and stderr of the subprocess. This method fails if executed by untrusted code.

Parameters:
command - a specified system command
Returns:
an instance of class Process
IOException

exec

public Process exec(String[] cmdarray)
             throws IOException
Executes the system command specified by cmdarray[0] with arguments specified by the strings in the rest of the array. Returns a Process which has methods for optaining the stdin, stdout, and stderr of the subprocess. This method fails if executed by untrusted code.

Returns:
an instance of class Process
IOException

exec

public Process exec(String[] cmdarray,
                    String[] envp)
             throws IOException
Executes the system command specified by cmdarray[0] with arguments specified by the strings in the rest of the array. Returns a Process which has methods for optaining the stdin, stdout, and stderr of the subprocess. This method fails if executed by untrusted code.

Parameters:
envp - array containing environment in format name=value
Returns:
an instance of class Process
IOException

freeMemory

public long freeMemory()
Returns the number of free bytes in system memory. This number is not always accurate because it is just an estimation of the available memory. More memory may be freed by calling System.gc() .


totalMemory

public long totalMemory()
Returns the total number of bytes in system memory.


gc

public void gc()
Runs the garbage collector.


runFinalization

public void runFinalization()
Runs the finalization methods of any objects pending finalization. Usually you will not need to call this method since finalization methods will be called asynchronously by the finalization thread. However, under some circumstances (like running out of a finalized resource) it can be useful to run finalization methods synchronously.


traceInstructions

public void traceInstructions(boolean on)
Enables/Disables tracing of instructions.

Parameters:
on - start tracing if true

traceMethodCalls

public void traceMethodCalls(boolean on)
Enables/Disables tracing of method calls.

Parameters:
on - start tracing if true

load

public void load(String filename)
Loads a dynamic library, given a complete path name. If you use this from java_g it will automagically insert "_g" before the ".so". Example: Runtime.getRuntime().load("/home/avh/lib/libX11.so");

Parameters:
filename - the file to load
Throws:
UnsatisfiedLinkError - If the file does not exist.
See Also:
getRuntime()

loadLibrary

public void loadLibrary(String libname)
Loads a dynamic library with the specified library name. The call to LoadLibrary() should be made in the static initializer of the first class that is loaded. Linking in the same library more than once is ignored.

Parameters:
libname - the name of the library
Throws:
UnsatisfiedLinkError - If the library does not exist.

getLocalizedInputStream

public InputStream getLocalizedInputStream(InputStream in)
Localize an input stream. A localized input stream will automatically translate the input from the local format to UNICODE.


getLocalizedOutputStream

public OutputStream getLocalizedOutputStream(OutputStream out)
Localize an output stream. A localized output stream will automatically translate the output from UNICODE to the local format.