List all System Properties in Java
This example show how you can list all system properties of a running java application. You can use this as a reference to look up which properties are by default available.
Print System Properties
You can easily print all the system properties to the System.out
console.
package com.memorynotfound;
public class ListAllSystemProperties {
public static void main(String... args) {
System.getProperties().list(System.out);
}
}
Loop over System Properties
The Sytem.getProperties().propertyNames();
returns an enumeration on which you can loop over all the system properties.
package com.memorynotfound;
import java.util.Enumeration;
import java.util.Properties;
public class ListAllSystemProperties {
public static void main(String... args) {
Properties systemProperties = System.getProperties();
Enumeration enuProp = systemProperties.propertyNames();
while (enuProp.hasMoreElements()) {
String propertyName = (String) enuProp.nextElement();
String propertyValue = systemProperties.getProperty(propertyName);
System.out.println(propertyName + ": " + propertyValue);
}
}
}
[...]
.Output all System Properties
java.runtime.name: Java(TM) SE Runtime Environment
sun.boot.library.path: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib
java.vm.version: 25.20-b23
user.country.format: BE
gopherProxySet: false
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.country: US
sun.java.launcher: SUN_STANDARD
sun.os.patch.level: unknown
java.vm.specification.name: Java Virtual Machine Specification
user.dir: /Users/memorynotfound/Documents/projects/memorynotfound/java/tutorials
java.runtime.version: 1.8.0_20-b26
java.awt.graphicsenv: sun.awt.CGraphicsEnvironment
java.endorsed.dirs: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/endorsed
os.arch: x86_64
java.io.tmpdir: /var/folders/ts/tv2s4k357c79jmw4_rkbt7b40000gn/T/
line.separator:
java.vm.specification.vendor: Oracle Corporation
os.name: Mac OS X
sun.jnu.encoding: UTF-8
java.library.path: /Users/memorynotfound/Library/Java/Extensions:/Library/Java/Extensions:/[...]
java.specification.name: Java Platform API Specification
java.class.version: 52.0
sun.management.compiler: HotSpot 64-Bit Tiered Compilers
os.version: 10.10.2
http.nonProxyHosts: local|*.local|169.254/16|*.169.254/16
user.home: /Users/memorynotfound
user.timezone: Europe/Brussels
java.awt.printerjob: sun.lwawt.macosx.CPrinterJob
file.encoding: UTF-8
java.specification.version: 1.8
user.name: memorynotfound
java.class.path: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/[...]
java.vm.specification.version: 1.8
sun.arch.data.model: 64
java.home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
sun.java.command: com.memorynotfound.ListAllSystemProperties
java.specification.vendor: Oracle Corporation
user.language: en
awt.toolkit: sun.lwawt.macosx.LWCToolkit
java.vm.info: mixed mode
java.version: 1.8.0_20
java.ext.dirs: /Users/memorynotfound/Library/Java/Extensions:/Library/[...]
sun.boot.class.path: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/[...]
java.vendor: Oracle Corporation
file.separator: /
java.vendor.url.bug: http://bugreport.sun.com/bugreport/
sun.cpu.endian: little
sun.io.unicode.encoding: UnicodeBig
socksNonProxyHosts: local|*.local|169.254/16|*.169.254/16
ftp.nonProxyHosts: local|*.local|169.254/16|*.169.254/16
sun.cpu.isalist: