java.lang.Object | +--java.lang.System
static java.io.PrintStream | err The standard output PrintStream. |
static java.io.InputStream | in The standard InputStream. |
static java.io.PrintStream | out The standard output PrintStream. |
static void | arraycopy(java.lang.Object src, int srcStart, java.lang.Object dest, int destStart, int len) Copy one array onto another from |
static long | currentTimeMillis() Get the current time, measured in the number of milliseconds from the beginning of Jan. |
static void | exit(int status) Terminate the Virtual Machine. |
static void | gc() Calls the garbage collector. |
static java.util.Properties | getProperties() Get all the system properties at once. |
static java.lang.String | getProperty(java.lang.String key) Get a single system property by name. |
static java.lang.String | getProperty(java.lang.String key, java.lang.String def) Get a single system property by name. |
static java.lang.SecurityManager | getSecurityManager() Get the current SecurityManager. |
static java.lang.String | getenv(java.lang.String name) This used to get an environment variable, but following Sun's lead, it now throws an Error. |
static int | identityHashCode(java.lang.Object o) Get a hash code computed by the VM for the Object. |
static void | load(java.lang.String filename) Load a code file using its explicit system-dependent filename. |
static void | loadLibrary(java.lang.String libname) Load a library using its explicit system-dependent filename. |
static java.lang.String | mapLibraryName(java.lang.String libname) Convert a library name to its platform-specific variant. |
static void | runFinalization() Runs object finalization on pending objects. |
static void | runFinalizersOnExit(boolean finalizeOnExit) Tell the Runtime whether to run finalization before exiting the JVM. |
static void | setErr(java.io.PrintStream err) Set #err to a new PrintStream. |
static void | setIn(java.io.InputStream in) Set #in to a new InputStream. |
static void | setOut(java.io.PrintStream out) Set #out to a new PrintStream. |
static void | setProperties(java.util.Properties properties) Set all the system properties at once. |
static java.lang.String | setProperty(java.lang.String key, java.lang.String value) Set a single system property by name. |
static synchronized void | setSecurityManager(java.lang.SecurityManager sm) Set the current SecurityManager. |
public static final PrintStream err
This corresponds to the C stderr and C++ cerr variables, which typically output error messages to the screen, but may be used to pipe output to other processes or files. That should all be transparent to you, however.
public static final InputStream in
This corresponds to the C stdin and C++ cin variables, which typically input from the keyboard, but may be used to pipe input from other processes or files. That should all be transparent to you, however.
public static final PrintStream out
This corresponds to the C stdout and C++ cout variables, which typically output normal messages to the screen, but may be used to pipe output to other processes or files. That should all be transparent to you, however.
public static void arraycopy(java.lang.Object src, int srcStart, java.lang.Object dest, int destStart, int len)
src[srcStart]
...
src[srcStart+len-1]
to dest[destStart]
...
dest[destStart+len-1]
. First, the arguments are validated:
neither array may be null, they must be of compatible types, and the
start and length must fit within both arrays. Then the copying starts,
and proceeds through increasing slots. If src and dest are the same
array, this will appear to copy the data to a temporary location first.
An ArrayStoreException in the middle of copying will leave earlier
elements copied, but later elements unchanged.
src
- the array to copy elements fromsrcStart
- the starting position in srcdest
- the array to copy elements todestStart
- the starting position in destlen
- the number of elements to copyNullPointerException
- if src or dest is nullArrayStoreException
- if src or dest is not an array, if they are
not compatible array types, or if an incompatible runtime type
is stored in destIndexOutOfBoundsException
- if len is negative, or if the start or
end copy position in either array is out of boundspublic static long currentTimeMillis()
java.util.Date
public static void exit(int status)
Runtime.getRuntime().exit(status)
, and never returns.
Obviously, a security check is in order, checkExit
.
status
- the exit status; by convention non-zero is abnormalSecurityException
- if permission is deniedRuntime#exit(int)
public static void gc()
Runtime.getRuntime().gc()
.
Runtime#gc()
public static Properties getProperties()
checkPropertiesAccess
. Note that a security manager may
allow getting a single property, but not the entire group.
The required properties include:
SecurityException
- if permission is deniedpublic static String getProperty(java.lang.String key)
checkPropertyAccess(key)
.
key
- the name of the system property to getSecurityException
- if permission is deniedNullPointerException
- if key is nullIllegalArgumentException
- if key is ""public static String getProperty(java.lang.String key, java.lang.String def)
checkPropertyAccess(key)
.
key
- the name of the system property to getdef
- the defaultSecurityException
- if permission is deniedNullPointerException
- if key is nullIllegalArgumentException
- if key is ""public static SecurityManager getSecurityManager()
public static String getenv(java.lang.String name)
getProperty
instead.
name
- the name of the environment variableError
- this is not supportedpublic static int identityHashCode(java.lang.Object o)
o
- the Object to get the hash code forpublic static void load(java.lang.String filename)
checkLink
. This just calls
Runtime.getRuntime().load(filename)
.
filename
- the code file to loadSecurityException
- if permission is deniedUnsatisfiedLinkError
- if the file cannot be loadedRuntime#load(String)
public static void loadLibrary(java.lang.String libname)
checkLink
. This just calls
Runtime.getRuntime().load(filename)
.
libname
- the library file to loadSecurityException
- if permission is deniedUnsatisfiedLinkError
- if the file cannot be loadedRuntime#load(String)
public static String mapLibraryName(java.lang.String libname)
loadLibrary
libname
- public static void runFinalization()
Runtime.getRuntime().runFinalization()
.
Runtime#runFinalization()
public static void runFinalizersOnExit(boolean finalizeOnExit)
checkExit(0)
. This
calls Runtime.getRuntime().runFinalizersOnExit()
.
finalizeOnExit
- whether to run finalizers on exitSecurityException
- if permission is deniedRuntime#runFinalizersOnExit()
public static void setErr(java.io.PrintStream err)
RuntimePermission("setIO")
.
err
- the new PrintStreamSecurityException
- if permission is deniedpublic static void setIn(java.io.InputStream in)
RuntimePermission("setIO")
.
in
- the new InputStreamSecurityException
- if permission is deniedpublic static void setOut(java.io.PrintStream out)
RuntimePermission("setIO")
.
out
- the new PrintStreamSecurityException
- if permission is deniedpublic static void setProperties(java.util.Properties properties)
checkPropertiesAccess
. Note that a security manager may
allow setting a single property, but not the entire group. An argument
of null resets the properties to the startup default.
properties
- the new set of system propertiesSecurityException
- if permission is deniedpublic static String setProperty(java.lang.String key, java.lang.String value)
checkPropertyAccess(key, "write")
.
key
- the name of the system property to setvalue
- the new valueSecurityException
- if permission is deniedNullPointerException
- if key is nullIllegalArgumentException
- if key is ""public static synchronized void setSecurityManager(java.lang.SecurityManager sm)
RuntimePermission("setSecurityManager")
is checked
first. Since this permission is denied by the default security manager,
setting the security manager is often an irreversible action.
Spec Note: Don't ask me, I didn't write it. It looks
pretty vulnerable; whoever gets to the gate first gets to set the policy.
There is probably some way to set the original security manager as a
command line argument to the VM, but I don't know it.
sm
- the new SecurityManagerSecurityException
- if permission is denied