|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Runtime
public class Runtime
Allows Java applications to interface with the environment in which they are
running. Applications can not create an instance of this class, but they can
get a singleton instance by invoking getRuntime().
System| Method Summary | |
|---|---|
void |
addShutdownHook(Thread hook)
Registers a virtual-machine shutdown hook. |
int |
availableProcessors()
Returns the number of processors available to the virtual machine. |
Process |
exec(String prog)
Executes the specified program in a separate native process. |
Process |
exec(String[] progArray)
Executes the specified command and its arguments in a separate native process. |
Process |
exec(String[] progArray,
String[] envp)
Executes the specified command and its arguments in a separate native process. |
Process |
exec(String[] progArray,
String[] envp,
File directory)
Executes the specified command and its arguments in a separate native process. |
Process |
exec(String prog,
String[] envp)
Executes the specified program in a separate native process. |
Process |
exec(String prog,
String[] envp,
File directory)
Executes the specified program in a separate native process. |
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 run the garbage collector. |
InputStream |
getLocalizedInputStream(InputStream stream)
Deprecated. Use InputStreamReader. |
OutputStream |
getLocalizedOutputStream(OutputStream stream)
Deprecated. Use OutputStreamWriter. |
static Runtime |
getRuntime()
Returns 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 dynamic library that is identified through the specified path. |
(package private) void |
load(String filename,
ClassLoader loader)
|
void |
loadLibrary(String libName)
Loads and links the library with the specified name. |
(package private) void |
loadLibrary(String libname,
ClassLoader loader)
|
long |
maxMemory()
Returns the maximum amount of memory that may be used by the virtual machine, or Long.MAX_VALUE if there is no such limit. |
boolean |
removeShutdownHook(Thread hook)
Unregisters 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 which is available to the running program. |
void |
traceInstructions(boolean enable)
Switches the output of debug information for instructions on or off. |
void |
traceMethodCalls(boolean enable)
Switches 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 |
|---|
public Process exec(String[] progArray)
throws IOException
exec(progArray, null, null).
progArray - the array containing the program to execute as well as any
arguments to the program.
Process object that represents the native
process.
IOException - if the requested program can not be executed.
SecurityException - if the current SecurityManager disallows program
execution.SecurityManager.checkExec(java.lang.String)
public Process exec(String[] progArray,
String[] envp)
throws IOException
envp.
Calling this method is equivalent to calling
exec(progArray, envp, null).
progArray - the array containing the program to execute as well as any
arguments to the program.envp - the array containing the environment to start the new process
in.
Process object that represents the native
process.
IOException - if the requested program can not be executed.
SecurityException - if the current SecurityManager disallows program
execution.SecurityManager.checkExec(java.lang.String)
public Process exec(String[] progArray,
String[] envp,
File directory)
throws IOException
envp
and the working directory specified by directory.
progArray - the array containing the program to execute as 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 the program. If null,
execute if in the same directory as the parent process.
Process object that represents the native
process.
IOException - if the requested program can not be executed.
SecurityException - if the current SecurityManager disallows program
execution.SecurityManager.checkExec(java.lang.String)
public Process exec(String prog)
throws IOException
exec(prog, null, null).
prog - the name of the program to execute.
Process object that represents the native
process.
IOException - if the requested program can not be executed.
SecurityException - if the current SecurityManager disallows program
execution.SecurityManager.checkExec(java.lang.String)
public Process exec(String prog,
String[] envp)
throws IOException
envp. Calling this
method is equivalent to calling exec(prog, envp, null).
prog - the name of the program to execute.envp - the array containing the environment to start the new process
in.
Process object that represents the native
process.
IOException - if the requested program can not be executed.
SecurityException - if the current SecurityManager disallows program
execution.SecurityManager.checkExec(java.lang.String)
public Process exec(String prog,
String[] envp,
File directory)
throws IOException
envp and the working
directory specified by directory.
prog - the name of the program to execute.envp - the array containing the environment to start the new process
in.directory - the directory in which to execute the program. If null,
execute if in the same directory as the parent process.
Process object that represents the native
process.
IOException - if the requested program can not be executed.
SecurityException - if the current SecurityManager disallows program
execution.SecurityManager.checkExec(java.lang.String)public void exit(int code)
runFinalizersOnExit(boolean) has been previously invoked with a
true argument, then all all objects will be properly
garbage-collected and finalized first.
code - the return code. By convention, non-zero return codes indicate
abnormal terminations.
SecurityException - if the current SecurityManager does not allow the
running thread to terminate the virtual machine.SecurityManager.checkExit(int)public long freeMemory()
public void gc()
public static Runtime getRuntime()
Runtime instance.
Runtime object for the current application.public void load(String pathName)
loadLibrary(String),
but it accepts a full path specification whereas loadLibrary just
accepts the name of the library to load.
pathName - the absolute (platform dependent) path to the library to load.
UnsatisfiedLinkError - if the library can not be loaded.
SecurityException - if the current SecurityManager does not allow to load
the library.SecurityManager.checkLink(java.lang.String)
void load(String filename,
ClassLoader loader)
public void loadLibrary(String libName)
libName - the name of the library to load.
UnsatisfiedLinkError - if the library can not be loaded.
SecurityException - if the current SecurityManager does not allow to load
the library.SecurityManager.checkLink(java.lang.String)
void loadLibrary(String libname,
ClassLoader loader)
public void runFinalization()
@Deprecated public static void runFinalizersOnExit(boolean run)
run - true to enable finalization on exit, false to
disable it.public long totalMemory()
public void traceInstructions(boolean enable)
enable - true to switch tracing on, false to switch it
off.public void traceMethodCalls(boolean enable)
enable - true to switch tracing on, false to switch it
off.@Deprecated public InputStream getLocalizedInputStream(InputStream stream)
InputStreamReader.
stream - the input stream to localize.
@Deprecated public OutputStream getLocalizedOutputStream(OutputStream stream)
OutputStreamWriter.
stream - the output stream to localize.
public void addShutdownHook(Thread hook)
Thread that is ready to run, but has not yet been started. All
registered shutdown hooks will be executed once the virtual machine shuts
down properly. A proper shutdown happens when either the
exit(int) method is called or the surrounding system decides to
terminate the application, for example in response to a CTRL-C or
a system-wide shutdown. A termination of the virtual machine due to the
halt(int) method, an Error or a SIGKILL, in
contrast, is not considered a proper shutdown. In these cases the
shutdown hooks will not be run.
Shutdown hooks are run concurrently and in an unspecified order. Hooks
failing due to an unhandled exception are not a problem, but the stack
trace might be printed to the console. Once initiated, the whole shutdown
process can only be terminated by calling halt().
If runFinalizersOnExit(boolean) has been called with a true argument, garbage collection and finalization will take place after
all hooks are either finished or have failed. Then the virtual machine
terminates.
It is recommended that shutdown hooks do not do any time-consuming activities, in order to not hold up the shutdown process longer than necessary.
hook - the shutdown hook to register.
IllegalArgumentException - if the hook has already been started or if it has already
been registered.
IllegalStateException - if the virtual machine is already shutting down.
SecurityException - if a SecurityManager is registered and the calling code
doesn't have the RuntimePermission("shutdownHooks").public boolean removeShutdownHook(Thread hook)
hook - the shutdown hook to remove.
true if the hook has been removed successfully; false otherwise.
IllegalStateException - if the virtual machine is already shutting down.
SecurityException - if a SecurityManager is registered and the calling code
doesn't have the RuntimePermission("shutdownHooks").public void halt(int code)
code - the return code. By convention, non-zero return codes indicate
abnormal terminations.
SecurityException - if the current SecurityManager does not allow the
running thread to terminate the virtual machine.SecurityManager.checkExit(int),
addShutdownHook(Thread),
removeShutdownHook(Thread),
runFinalizersOnExit(boolean)public int availableProcessors()
public long maxMemory()
Long.MAX_VALUE if there is no such limit.
|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||