Java System.getProperties() – Examples
In this tutorial, we will learn about the Java System.getProperties() function, and learn how to use this function to get the properties of the system on which this JVM runs, with the help of examples.
getProperties()
System.getProperties() gets the current system properties on which this JVM is running.
Syntax
The syntax of getProperties() function is
</>
Copy
getProperties()
Returns
The function returns static Properties object.
Example 1 – getProperties()
In this example, we will get the properties of the system on which this JVM runs using System.getProperties(), and print them to console.
Java Program
</>
Copy
import java.util.Properties;
public class Example {
public static void main(String[] args) {
Properties jvm = System.getProperties();
jvm.list(System.out);
}
}
Output
-- listing properties --
sun.desktop=windows
awt.toolkit=sun.awt.windows.WToolkit
java.specification.version=10
file.encoding.pkg=sun.io
sun.cpu.isalist=amd64
sun.jnu.encoding=Cp1252
java.class.path=C:\workspace\eclipse\JavaTutorial\bin...
java.vm.vendor="Oracle Corporation"
sun.arch.data.model=64
user.variant=
java.vendor.url=http://java.oracle.com/
user.timezone=
os.name=Windows 10
java.vm.specification.version=10
sun.java.launcher=SUN_STANDARD
user.country=US
sun.boot.library.path=C:\Program Files\Java\jre-10.0.1\bin
sun.java.command=Example
jdk.debug=release
sun.cpu.endian=little
user.home=C:\Users\TutorialKart
user.language=en
java.specification.vendor=Oracle Corporation
java.version.date=2018-04-17
java.home=C:\Program Files\Java\jre-10.0.1
file.separator=\
java.vm.compressedOopsMode=Zero based
line.separator=
java.specification.name=Java Platform API Specification
java.vm.specification.vendor=Oracle Corporation
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
user.script=
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=10.0.1+10
user.name=TutorialKart
path.separator=;
os.version=10.0
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=UTF-8
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vendor.version=18.3
java.vendor.url.bug=http://bugreport.java.com/bugreport/
java.io.tmpdir=C:\Users\TutorialKart\AppData\Local\Temp\
java.version=10.0.1
user.dir=C:\workspace\eclipse\JavaTutorial
os.arch=amd64
java.vm.specification.name=Java Virtual Machine Specification
java.awt.printerjob=sun.awt.windows.WPrinterJob
sun.os.patch.level=
java.library.path=C:\Program Files\Java\jre-10.0.1\bin;...
java.vendor=Oracle Corporation
java.vm.info=mixed mode
java.vm.version=10.0.1+10
sun.io.unicode.encoding=UnicodeLittle
java.class.version=54.0
Conclusion
In this Java Tutorial, we have learnt the syntax of Java System.getProperties() function, and also learnt how to use this function with the help of examples.