Java System Methods

Beginner
6 min read
Updated: Nov 2026
25 method guides
Method index

About This Index

This page is the Java System Methods index: every static method of the java.lang.System class, each with a full guide covering syntax, all overloads, parameters, return value, exceptions, three runnable examples, and FAQs. The examples only print values that are the same on every computer (true/false checks, lengths, and text the program creates itself), so the output shown is the output you get.

Learn what the System class is on the System hub. Use this page when you need a specific method such as arraycopy(), getProperty(), or nanoTime(). Examples compile on Java 8 and later, except where a page says it needs a newer version (for example getLogger(), which needs Java 9).

System talks to the outside world.

Many results depend on the computer: the clock, the operating system, environment variables, or how the program was started. Each guide explains which part is fixed and which part can differ.

How to Call a System Method

Every method here is static and java.lang needs no import: write the class name, a dot, and the method:

Java
long start = System.nanoTime();                 // timer start
String home = System.getProperty("user.home");   // a system property
String path = System.getenv("PATH");             // an environment variable
System.arraycopy(src, 0, dest, 0, src.length);   // copy an array
System.exit(0);                                  // end the program

Java System Methods Table

All method guides in this Java tutorial series (25 tutorials), grouped by purpose.

Copy, time, and memory

6 methods

Copy parts of arrays quickly, read the clock, measure how long code takes, and work with object identity and garbage collection.

MethodDescriptionTutorial
arraycopy()Copy a range of elements from one array into another, or shift elements inside the same array.Try it
currentTimeMillis()The current wall-clock time in milliseconds since January 1, 1970 UTC.Try it
nanoTime()A high-resolution timer value in nanoseconds for measuring elapsed time.Try it
identityHashCode()The default, identity-based hash code of an object, even if hashCode() is overridden.Try it
gc()Suggest that the JVM runs the garbage collector now. Only a hint.Try it
runFinalization()Ask the JVM to run finalize() methods of discarded objects. Deprecated for removal since Java 18.Try it

Program end and text

2 methods

End a program with an exit status code, and write line breaks that match the operating system.

MethodDescriptionTutorial
exit()Stop the JVM with an exit status code: 0 for success, nonzero for an error.Try it
lineSeparator()The line break of the current platform: "\n" on Linux and macOS, "\r\n" on Windows.Try it

System properties and environment

6 methods

Read and change Java system properties (key and value settings inside the JVM) and read environment variables from the operating system.

MethodDescriptionTutorial
getProperty()Read one system property, optionally with a default value.Try it
setProperty()Set a system property and get back its previous value.Try it
clearProperty()Remove a system property and get back the value it had.Try it
getProperties()Get all system properties as one live Properties object.Try it
setProperties()Replace the whole set of system properties, or reset it with null.Try it
getenv()Read one environment variable, or all of them as a read-only Map.Try it

Streams and console

5 methods

Swap the standard input, output, and error streams, get the interactive console, and pick up an inherited network channel.

MethodDescriptionTutorial
setIn()Replace the standard input stream System.in, for example with prepared test input.Try it
setOut()Redirect standard output System.out, for example to capture printed text.Try it
setErr()Redirect the standard error stream System.err to another PrintStream.Try it
console()Get the Console of the interactive terminal, or null when there is none.Try it
inheritedChannel()The network channel inherited from the process that started the JVM, usually null.Try it

Native libraries, logging, and security

6 methods

Load native (C or C++) libraries, get a platform logger, and deal with the deprecated Security Manager.

MethodDescriptionTutorial
load()Load a native library from an absolute file path.Try it
loadLibrary()Load a native library by its short name, searched in java.library.path.Try it
mapLibraryName()Turn a short library name into the platform file name, such as libhello.so or hello.dll.Try it
getLogger()Get a System.Logger for platform logging with levels such as INFO and DEBUG (Java 9+).Try it
getSecurityManager()Get the installed SecurityManager, which is null on modern Java (deprecated).Try it
setSecurityManager()Install a SecurityManager. Throws UnsupportedOperationException on Java 18+ by default.Try it

Frequently Asked Questions

They are the static methods of java.lang.System, a built-in class that connects your program to its environment: copying arrays, reading the clock, system properties and environment variables, the standard input, output, and error streams, exit codes, and native libraries.
This index lists 25 guides, from arraycopy() and currentTimeMillis() to setProperty() and setSecurityManager(), grouped by what they do.
Neither. System lives in java.lang, which every Java file sees automatically, and it cannot be instantiated. Call the methods on the class name, for example System.nanoTime().
runFinalization() is deprecated for removal since Java 18, and getSecurityManager() and setSecurityManager() since Java 17. Since Java 18, setSecurityManager() throws UnsupportedOperationException unless the JVM is started with -Djava.security.manager=allow.
Read the Java System hub first. Then open arraycopy(), nanoTime(), getProperty(), getenv(), setOut(), and exit() from the tables below.

Start with arraycopy()

Copy part of an array into another array, or shift elements inside the same array.

arraycopy() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful