Print or list all system properties using java8 streams

  1. System properties are vital for our application development.
  2. Sometimes, we need to go through our system properties to trouble shoot our application.
  3. In current post, we will list/print/display all our system properties.
  4. We will loop or iterate through all system properties using forEach method (Java 8 feature).

1. Program – print all system properties – java8 streams.

package org.learn;

import java.util.Properties;

public class ListSystemProperties {
    public static void main(String[] args) {
        Properties properties = System.getProperties();
        System.out.println("Display or print all System properties :");
        properties.forEach(
                        (key,value)
                              ->
                        System.out.println(key + "=" +value)
                );
    }
}

2. Output: list system properties – java 8 lambda streams.

Display or print all System properties :
sun.cpu.isalist = amd64
sun.desktop = windows
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
file.separator = \
java.vendor = Oracle Corporation
java.version = 1.8.0_101
java.vm.info = mixed mode
awt.toolkit = sun.awt.windows.WToolkit
user.language = en
java.specification.vendor = Oracle Corporation
sun.java.command = com.intellij.rt.execution.application.AppMain org.learn.ListSystemProperties
java.home = C:\Program Files\Java\jdk1.8.0_101\jre
sun.arch.data.model = 64
java.vm.specification.version = 1.8
file.encoding = UTF-8
idea.launcher.bin.path = C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2.4\bin
java.specification.version = 1.8
java.awt.printerjob = sun.awt.windows.WPrinterJob
user.timezone = 
os.version = 10.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
java.specification.name = Java Platform API Specification
java.class.version = 52.0
os.name = Windows 10
user.variant = 
java.vm.specification.vendor = Oracle Corporation
line.separator = 

java.endorsed.dirs = C:\Program Files\Java\jdk1.8.0_101\jre\lib\endorsed
os.arch = amd64
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.runtime.version = 1.8.0_101-b13
java.vm.specification.name = Java Virtual Machine Specification
user.dir = D:\Project\ONP_30062015\EqualsVs==Operator
user.country = US
user.script = 
sun.java.launcher = SUN_STANDARD
sun.os.patch.level = 
idea.launcher.port = 7534
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg = sun.io
path.separator = ;
java.vm.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
sun.boot.library.path = C:\Program Files\Java\jdk1.8.0_101\jre\bin

...............Rest of properties....................
Scroll to Top