Top Description Inners Fields Constructors Methods
java.lang

public final Class System

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .BufferedOutputStream, .Console, .FileDescriptor, .FileInputStream, .FileOutputStream, .IOException, .InputStream, .OutputStream, .PrintStream, java.lang.annotation.Annotation, java.lang.foreign.MemorySegment, java.lang.invoke.MethodHandle, .MethodType, .StringConcatFactory, java.lang.module.ModuleDescriptor, java.lang.reflect.Constructor, .Executable, .Method, .Modifier, java.net.URI, .URL, java.nio.channels.Channel, java.nio.channels.spi.SelectorProvider, java.nio.charset.CharacterCodingException, .Charset, java.security.AccessControlContext, .AccessController, .CodeSource, .PrivilegedAction, .ProtectionDomain, java.util.Collections, .List, .Locale, .Map, .Objects, .Properties, .PropertyPermission, .ResourceBundle, .Set, .WeakHashMap, java.util.concurrent.Callable, .ConcurrentHashMap, java.util.function.Supplier, java.util.stream.Stream, jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder, .LoggerFinderLoader, .LazyLoggers, .LocalizedLoggerWrapper, jdk.internal.misc.Blocker, .CarrierThreadLocal, .Unsafe, .VM, jdk.internal.util.StaticProperty, .SystemProps, jdk.internal.module.ModuleBootstrap, .ServicesCatalog, jdk.internal.reflect.CallerSensitive, .Reflection, jdk.internal.access.JavaLangAccess, .SharedSecrets, jdk.internal.vm.Continuation, .ContinuationScope, .StackableScope, .ThreadContainer, jdk.internal.vm.annotation.IntrinsicCandidate, .Stable, sun.nio.fs.DefaultFileSystemProvider, sun.reflect.annotation.AnnotationType, sun.nio.ch.Interruptible, sun.nio.cs.UTF_8, sun.security.util.SecurityConstants

The System class contains several useful class fields and methods. It cannot be instantiated. Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
System.In

System.in.

public static interface
System.Logger

System.Logger instances log messages that will be routed to the underlying logging framework the LoggerFinder uses.

public abstract static class
System.LoggerFinder

The LoggerFinder service is responsible for creating, managing, and configuring loggers to the underlying framework it uses.

private static class
System.Out

System.out/System.err wrap this output stream.

Field Summary

Modifier and TypeField and Description
private static int
pack-priv static ModuleLayer
private static volatile Console
public static final PrintStream
err

The "standard" error output stream.

public static final InputStream
in

The "standard" input stream.

private static PrintStream
private static InputStream
private static String
private static final int
private static final int
private static String
public static final PrintStream
out

The "standard" output stream.

private static Properties
props

System properties.

private static volatile SecurityManager
security

References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
private
System()

Don't let anyone instantiate this class

Method Summary

Modifier and TypeMethod and Description
private static boolean
public static native void
arraycopy(Object
the source array.
src
,
int
starting position in the source array.
srcPos
,
Object
the destination array.
dest
,
int
starting position in the destination data.
destPos
,
int
the number of array elements to be copied.
length
)

Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

private static void
private static void
public static String

Returns:

the previous string value of the system property, or null if there was no property with that key.
clearProperty
(String
the name of the system property to be removed.
key
)

Removes the system property indicated by the specified key.

private static URL
codeSource(Class<?> clazz)

public static Console

Returns:

The system console, if any, otherwise null.
console
()

Returns the unique Console object associated with the current Java virtual machine, if any.

private static Properties
createProperties(Map<String, String> initialProps)

Create the Properties object from a map - masking out system properties that are not intended for public access.

public static native long

Returns:

the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
currentTimeMillis
()

Returns the current time in milliseconds.

public static void
exit(int
exit status.
status
)

Initiates the shutdown sequence of the Java Virtual Machine.

public static void
gc()

Runs the garbage collector in the Java Virtual Machine.

public static String

Returns:

the string value of the variable, or null if the variable is not defined in the system environment
getenv
(String
the name of the environment variable
name
)

Gets the value of the specified environment variable.

public static Map<String, String>

Returns:

the environment as a map of variable names to values
getenv
()

Returns an unmodifiable string map view of the current system environment.

public static System.Logger

Returns:

an instance of Logger that can be used by the calling class.
getLogger
(String
the name of the logger.
name
)

Returns an instance of Logger for the caller's use.

public static System.Logger

Returns:

an instance of Logger which will use the provided resource bundle for message localization.
getLogger
(String
the name of the logger.
name
,
ResourceBundle
a resource bundle.
bundle
)

Returns a localizable instance of Logger for the caller's use.

public static Properties

Returns:

the system properties
getProperties
()

Determines the current system properties.

public static String

Returns:

the string value of the system property, or null if there is no property with that key.
getProperty
(String
the name of the system property.
key
)

Gets the system property indicated by the specified key.

public static String

Returns:

the string value of the system property, or the default value if there is no property with that key.
getProperty
(String
the name of the system property.
key
,
String
a default value.
def
)

Gets the system property indicated by the specified key.

public static SecurityManager

Returns:

if a security manager has already been established for the current application, then that security manager is returned; otherwise, null is returned.
getSecurityManager
()
Deprecated for removal since 17. This method is only useful in conjunction with the Security Manager, which is deprecated and subject to removal in a future release.

Gets the system-wide security manager.

public static native int

Returns:

the hashCode
identityHashCode
(Object
object for which the hashCode is to be calculated
x
)

Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode().

private static void
implSetSecurityManager(SecurityManager sm)
References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

public static Channel

Returns:

The inherited channel, if any, otherwise null.
inheritedChannel
()

Returns the channel inherited from the entity that created this Java virtual machine.

private static void
initPhase1()

Initialize the system class.

private static int
initPhase2(boolean printToStderr, boolean printStackTrace)

private static void
public static String

Returns:

the system-dependent line separator string
lineSeparator
()

Returns the system-dependent line separator string.

public static void
load(String
the file to load.
filename
)

Loads the native library specified by the filename argument.

public static void
loadLibrary(String
the name of the library.
libname
)

Loads the native library specified by the libname argument.

private static void
logInitException(boolean
to print to stderr rather than stdout
printToStderr
,
boolean
to print the stack trace
printStackTrace
,
String
the message to print before the exception, can be null
msg
,
Throwable
the exception or error
e
)

Logs an exception/error at initialization time to stdout or stderr.

public static native String

Returns:

a platform-dependent native library name.
mapLibraryName
(String
the name of the library.
libname
)

Maps a library name into a platform-specific string representing a native library.

public static native long

Returns:

the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds
nanoTime
()

Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.

private static PrintStream
newPrintStream(OutputStream out, String enc)

Create PrintStream for stdout/err based on encoding.

private static native void
public static void
runFinalization()
Deprecated for removal since 18. Finalization has been deprecated for removal.

Runs the finalization methods of any objects pending finalization.

public static void
setErr(PrintStream
the new standard error output stream.
err
)

Reassigns the "standard" error output stream.

private static native void
public static void
setIn(InputStream
the new standard input stream.
in
)

Reassigns the "standard" input stream.

private static native void
private static void
public static void
setOut(PrintStream
the new standard output stream
out
)

Reassigns the "standard" output stream.

private static native void
public static void
setProperties(Properties
the new system properties.
props
)

Sets the system properties to the Properties argument.

public static String

Returns:

the previous value of the system property, or null if it did not have one.
setProperty
(String
the name of the system property.
key
,
String
the value of the system property.
value
)

Sets the system property indicated by the specified key.

public static void
setSecurityManager(SecurityManager
the security manager or null
sm
)
Deprecated for removal since 17. This method is only useful in conjunction with the Security Manager, which is deprecated and subject to removal in a future release.

Sets the system-wide security manager.

private static synchronized void
setSecurityManager0(final SecurityManager s)
References Deprecated SecurityManager is deprecated or references (maybe indirectly) at least one deprecated element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait