java.lang.Object | |
↳ | java.lang.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().
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Registers a virtual-machine shutdown hook.
| |||||||||||
Returns the number of processors available to the virtual machine.
| |||||||||||
Executes the specified command and its arguments in a separate native
process.
| |||||||||||
Executes the specified program in a separate native process.
| |||||||||||
Executes the specified program in a separate native process.
| |||||||||||
Executes the specified program in a separate native process.
| |||||||||||
Executes the specified command and its arguments in a separate native
process.
| |||||||||||
Executes the specified command and its arguments in a separate native
process.
| |||||||||||
Causes the virtual machine to stop running and the program to exit.
| |||||||||||
Returns the amount of free memory resources which are available to the
running program.
| |||||||||||
Indicates to the virtual machine that it would be a good time to run the
garbage collector.
| |||||||||||
This method is deprecated.
Use InputStreamReader.
| |||||||||||
This method is deprecated.
Use OutputStreamWriter.
| |||||||||||
Returns the single
Runtime instance. | |||||||||||
Causes the virtual machine to stop running, and the program to exit.
| |||||||||||
Loads and links the dynamic library that is identified through the
specified path.
| |||||||||||
Loads and links the library with the specified name.
| |||||||||||
Returns the maximum amount of memory that may be used by the virtual
machine, or
Long.MAX_VALUE if there is no such limit. | |||||||||||
Unregisters a previously registered virtual machine shutdown hook.
| |||||||||||
Provides a hint to the virtual machine that it would be useful to attempt
to perform any outstanding object finalizations.
| |||||||||||
This method is deprecated.
This method is unsafe.
| |||||||||||
Returns the total amount of memory which is available to the running
program.
| |||||||||||
Switches the output of debug information for instructions on or off.
| |||||||||||
Switches the output of debug information for methods on or off.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Registers a virtual-machine shutdown hook. A shutdown hook is a
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"). |
Returns the number of processors available to the virtual machine. The Android reference implementation (currently) always returns 1.
Executes the specified command and its arguments in a separate native
process. The new process uses the environment provided in 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. |
Executes the specified program in a separate native process. The new
process uses the environment provided in 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. |
Executes the specified program in a separate native process. The new
process inherits the environment of the caller. Calling this method is
equivalent to calling 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. |
Executes the specified program in a separate native process. The new
process uses the environment provided in 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. |
Executes the specified command and its arguments in a separate native
process. The new process inherits the environment of the caller. Calling
this method is equivalent to calling 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. |
Executes the specified command and its arguments in a separate native
process. The new process uses the environment provided in 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. |
Causes the virtual machine to stop running and the program to exit. If
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. |
---|
Returns the amount of free memory resources which are available to the running program.
Indicates to the virtual machine that it would be a good time to run the garbage collector. Note that this is a hint only. There is no guarantee that the garbage collector will actually be run.
This method is deprecated.Use InputStreamReader.
Returns the localized version of the specified input stream. The input stream that is returned automatically converts all characters from the local character set to Unicode after reading them from the underlying stream.
stream | the input stream to localize. |
---|
This method is deprecated.Use OutputStreamWriter.
Returns the localized version of the specified output stream. The output stream that is returned automatically converts all characters from Unicode to the local character set before writing them to the underlying stream.
stream | the output stream to localize. |
---|
Returns the single Runtime
instance.
Runtime
object for the current application.Causes the virtual machine to stop running, and the program to exit. Neither shutdown hooks nor finalizers are run before.
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. |
---|
Loads and links the dynamic library that is identified through the
specified path. This method is similar to 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. |
Loads and links the library with the specified name. The mapping of the specified library name to the full path for loading the library is implementation-dependent.
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. |
Returns the maximum amount of memory that may be used by the virtual
machine, or Long.MAX_VALUE
if there is no such limit.
Unregisters a previously registered virtual machine shutdown 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"). |
Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.
This method is deprecated.This method is unsafe.
Sets the flag that indicates whether all objects are finalized when the virtual machine is about to exit. Note that all finalization which occurs when the system is exiting is performed after all running threads have been terminated.
run | true to enable finalization on exit, false to
disable it. |
---|
Returns the total amount of memory which is available to the running program.
Switches the output of debug information for instructions on or off. For the Android 1.0 reference implementation, this method does nothing.
enable | true to switch tracing on, false to switch it
off. |
---|
Switches the output of debug information for methods on or off.
enable | true to switch tracing on, false to switch it
off. |
---|