Java.lang.System Class

Java.lang.System Class


The java.lang.System class contains several useful class fields and methods. It cannot be instantiated.Facilities provided by System:

  • standard output
  • error output streams
  • standard input and access to externally defined properties and environment variables.
  • A utility method for quickly copying a portion of an array.
  • a means of loading files and libraries

Class declaration

Following is the declaration for java.lang.System class:

public final class System
   extends Object


Following are the fields for java.lang.System class:

  • static PrintStream err — This is the “standard” error output stream.
  • static InputStream in — This is the “standard” input stream.
  • static PrintStream out — This is the “standard” output stream.

Class methods

S.N.Method & Description
1static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

This method copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

2static String clearProperty(String key)

This method removes the system property indicated by the specified key.

3static Console console()

This method returns the unique Console object associated with the current Java virtual machine, if any.

4static long currentTimeMillis()

This method returns the current time in milliseconds.

5static void exit(int status)

This method terminates the currently running Java Virtual Machine.

6static void gc()

This method runs the garbage collector.

7static Map<String,String> getenv()

This method returns an unmodifiable string map view of the current system environment.

8static String getenv(String name)

This method gets the value of the specified environment variable.

9static Properties getProperties()

This method determines the current system properties.

10static String getProperty(String key)

This method gets the system property indicated by the specified key.

11static String getProperty(String key, String def)

This method gets the system property indicated by the specified key.

12static SecurityManager getSecurityManager()

This method gets the system security interface.

13static int identityHashCode(Object x)

This method 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().

14static Channel inheritedChannel()

This method returns the channel inherited from the entity that created this Java virtual machine.

15static void load(String filename)

This method loads a code file with the specified filename from the local file system as a dynamic library.

16static void loadLibrary(String libname)This method loads the system library specified by the libname argument.
17static String mapLibraryName(String libname)

This method maps a library name into a platform-specific string representing a native library.

18static long nanoTime()

This method returns the current value of the most precise available system timer, in nanoseconds.

19static void runFinalization()

This method runs the finalization methods of any objects pending finalization.

20static void setErr(PrintStream err)

This method reassigns the “standard” error output stream.

21static void setIn(InputStream in)

This method reassigns the “standard” input stream.

22static void setOut(PrintStream out)

This method reassigns the “standard” output stream.

23static void setProperties(Properties props)

This method sets the system properties to the Properties argument.

24static String setProperty(String key, String value)

This method sets the system property indicated by the specified key.

25static void setSecurityManager(SecurityManager s)

This method sets the System security.

Methods inherited

This class inherits methods from the following classes:

  • java.lang.Object

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.