How to Display System Properties in Java


Here we may learn about how to get system properties visa System class. At the same time, we may also get the method to get and print all system properties.

Source Code

package com.beginner.examples;

import java.util.Properties;

 
public class SystemInfoExample {
	
	public static void main(String args[])
	{		 
		Properties prop = System.getProperties();
		//list all system properties
		prop.list(System.out);
	}
 
}

Output:

-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=D:JAVAENVjdk180jrebin
java.vm.version=25.131-b11
java.vm.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
path.separator=;
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg=sun.io
user.script=
user.country=CN
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 1
java.vm.specification.name=Java Virtual Machine Specification
user.dir=D:Workspacescases
java.runtime.version=1.8.0_131-b11
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=D:JAVAENVjdk180jrelibendorsed
os.arch=amd64
java.io.tmpdir=C:UsersjiangAppDataLocalTemp
line.separator=

java.vm.specification.vendor=Oracle Corporation
user.variant=
os.name=Windows 7
sun.jnu.encoding=GBK
java.library.path=D:JAVAENVjdk180bin;C:windowsSun...
java.specification.name=Java Platform API Specification
java.class.version=52.0
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
os.version=6.1
user.home=C:Usersjiang
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=GBK
java.specification.version=1.8
user.name=jiang
java.class.path=D:Workspacescasesbin;D:Workspaces...
java.vm.specification.version=1.8
sun.arch.data.model=64
java.home=D:JAVAENVjdk180jre
sun.java.command=com.beginner.examples.SystemInfoExample
java.specification.vendor=Oracle Corporation
user.language=zh
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode
java.version=1.8.0_131
java.ext.dirs=D:JAVAENVjdk180jrelibext;C:wind...
sun.boot.class.path=D:JAVAENVjdk180jrelibresources.j...
java.vendor=Oracle Corporation
file.separator=
java.vendor.url.bug=http://bugreport.sun.com/bugreport/
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=amd64

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments