Javaのシステムプロパティの一覧表示

過去に何度か同じ使い捨てのコードを書いたので、また必要になった時のために残しておく。

public class Main {

    public static void main(String[] args) {
        System.getProperties()
                .entrySet()
                .stream()
                .sorted((x, y) -> x.getKey().toString().compareTo(y.getKey().toString()))
                .forEach(entry -> System.out.println(entry.getKey() + " = " + entry.getValue()));
    }
}

出力例は以下。 line.separatorの次の行が空行になっているのは、line.separatorの値が改行であり、そのため改行を2連続で出力したため。

awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.printerjob = sun.print.PSPrinterJob
java.class.path = target/classes/
java.class.version = 52.0
java.endorsed.dirs = /opt/java/jdk1.8.0_131/jre/lib/endorsed
java.ext.dirs = /opt/java/jdk1.8.0_131/jre/lib/ext:/usr/java/packages/lib/ext
java.home = /opt/java/jdk1.8.0_131/jre
java.io.tmpdir = /tmp
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.8.0_131-b11
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.8
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.8.0_131
java.vm.info = mixed mode
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 1.8
java.vm.vendor = Oracle Corporation
java.vm.version = 25.131-b11
line.separator = 

os.arch = amd64
os.name = Linux
os.version = 4.4.0-79-generic
path.separator = :
sun.arch.data.model = 64
sun.boot.class.path = /opt/java/jdk1.8.0_131/jre/lib/resources.jar:/opt/java/jdk1.8.0_131/jre/lib/rt.jar:/opt/java/jdk1.8.0_131/jre/lib/sunrsasign.jar:/opt/java/jdk1.8.0_131/jre/lib/jsse.jar:/opt/java/jdk1.8.0_131/jre/lib/jce.jar:/opt/java/jdk1.8.0_131/jre/lib/charsets.jar:/opt/java/jdk1.8.0_131/jre/lib/jfr.jar:/opt/java/jdk1.8.0_131/jre/classes
sun.boot.library.path = /opt/java/jdk1.8.0_131/jre/lib/amd64
sun.cpu.endian = little
sun.cpu.isalist = 
sun.desktop = gnome
sun.io.unicode.encoding = UnicodeLittle
sun.java.command = Main
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = UTF-8
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.os.patch.level = unknown
user.country = JP
user.dir = /var/src/class-loader-introspector
user.home = /home/redj
user.language = ja
user.name = redj
user.timezone =