System

Name

System

Synopsis

Description

The System class provides access to various information about the operating system environment in which a program is running. For example, the System class defines variables that allow access to the standard I/O streams and methods that allow a program to run the garbage collector and stop the Java virtual machine.

All of the variables and methods in the System class are static. In other words, it is not necessary to create an instance of the System class in order to use its variables and methods. In fact, the System class does not define any public constructors, so it cannot be instantiated.

The System class supports the concept of system properties that can be queried and set. The following properties are guaranteed always to be defined:

Property Name Description
file.encoding The character encoding for the default locale (Java 1.1 only)
file.encoding.pkg The package that contains converters between local encodings and Unicode (Java 1.1 only)
file.separator File separator ('/' on UNIX, ' \' on Windows)
java.class.path The class path
java.class.version Java class version number
java.compiler The just-in-time compiler to use, if any (Java 1.1 only)
java.home Java installation directory
java.vendor Java vendor-specific string
java.vendor.url Java vendor URL
java.version Java version number
line.separator Line separator(' \n' on UNIX, ' \r\n' on Windows)
os.arch Operating system architecture
os.name Operating system name
os.version Operating system version
path.separator Path separator (':' on UNIX, ',' on Windows)
user.dir User's current working directory when the properties were initialized
user.home User's home directory
user.language The two-letter language code of the default locale (Java 1.1 only)
user.name User's account name
user.region The two-letter country code of the default locale (Java 1.1 only)
user.timezone The default time zone (Java 1.1 only)

Additional properties may be defined by the run-time environment. The -D command-line option can be used to define system properties when a program is run.

The Runtime class is related to the System class; it provides access to information about the environment in which a program is running.

Class Summary

public final class java.lang.System extends java.lang.Object {
 // Constants public static final PrintStream err;
public static final InputStream in;
public static final PrintStream out; // Class Methods public static void arraycopy(Object src, int srcOffset, Object dst, int dstOffset, int length);
public static long currentTimeMillis();
public static void exit(int status);
public static void gc();
public static Properties getProperties();
public static String getProperty(String key);
public static String getProperty(String key, String default);
public static SecurityManager getSecurityManager();
public static String getenv(String name); // Deprecated in 1.1 public static native int identityHashCode(Object x); // New in 1.1 public static void load(String filename);
public static void loadLibrary(String libname);
public static void runFinalization();
public static void runFinalizersOnExit(boolean value); // New in 1.1 public static void setErr(PrintStream err); // New in 1.1 public static void setIn(InputStream in); // New in 1.1 public static void setOut(PrintStream out); // New in 1.1 public static void setProperties(Properties props);
public static void setSecurityManager(SecurityManager s);
}

Variables

err

public static final PrintStream err

in

public static final InputStream in

out

public static final PrintStream out

Class Methods

arraycopy

public static void arraycopy(Object src, int src_position, Object dst, int dst_position, int length)

currentTimeMillis

public static native long currentTimeMillis()

exit

public static void exit(int status)

gc

public static void gc()

getProperties

public static Properties getProperties()

getProperty

public static String getProperty(String key)

public static String getProperty(String key, String def)

getSecurityManager

public static SecurityManager getSecurityManager()

getenv

public static String getenv(String name)

identityHashCode

public static native int identityHashCode(Object x)

load

public void load(String filename)

loadLibrary

public void loadLibrary(String libname)

runFinalization

public static void runFinalization()

runFinalizersOnExit

public static void runFinalizersOnExit(boolean value)

setErr

public static void setErr(PrintStream err)

setIn

public static void setIn(InputStream in)

setOut

public static void setOut(PrintStream out)

setProperties

public static void setProperties(Properties props)

setSecurityManager

public static void setSecurityManager(SecurityManager s)

Inherited Methods

Method Inherited From Method Inherited From
clone() Object equals(Object) Object
finalize() Object getClass() Object
hashCode() Object notify() Object
notifyAll() Object toString() Object
wait() Object wait(long) Object
wait(long, int) Object

See Also

Assignment Compatibility; Errors; Exceptions; Object; Object Destruction; Process; Runtime; SecurityManager