listProperties.java
import java.util.Properties;
import java.util.Set;
class listProperties {
public static void main(String[] args) {
Properties properties = System.getProperties();
System.out.println(properties.toString());
System.out.println("\n");
Set<String> setPropertyNames =
properties.stringPropertyNames();
for (String propName : setPropertyNames) {
System.out.println(
propName + " : " +
System.getProperty(propName));
}
}
}
To compile listProperties.java
$ javac listProperties.java
Run generated listProperties.class
$ java listProperties
The result will be something like:
pi@raspberrypi ~/worksJava $ java listProperties
{java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=/opt/jdk1.8.0/jre/lib/arm, java.vm.version=25.0-b69, java.vm.vendor=Oracle Corporation, java.vendor.url=http://java.oracle.com/, path.separator=:, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=GB, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/pi/worksJava, java.runtime.version=1.8.0-b128, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/opt/jdk1.8.0/jre/lib/endorsed, os.arch=arm, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Oracle Corporation, os.name=Linux, sun.jnu.encoding=UTF-8, java.library.path=/usr/java/packages/lib/arm:/lib:/usr/lib, java.specification.name=Java Platform API Specification, java.class.version=52.0, sun.management.compiler=HotSpot Client Compiler, os.version=3.10.28+, user.home=/home/pi, sun.arch.abi=gnueabihf, user.timezone=Asia/Hong_Kong, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=UTF-8, java.specification.version=1.8, java.class.path=., user.name=pi, java.vm.specification.version=1.8, sun.java.command=listProperties, java.home=/opt/jdk1.8.0/jre, sun.arch.data.model=32, user.language=en, java.specification.vendor=Oracle Corporation, awt.toolkit=sun.awt.X11.XToolkit, java.vm.info=mixed mode, java.version=1.8.0, java.ext.dirs=/opt/jdk1.8.0/jre/lib/ext:/usr/java/packages/lib/ext, sun.boot.class.path=/opt/jdk1.8.0/jre/lib/resources.jar:/opt/jdk1.8.0/jre/lib/rt.jar:/opt/jdk1.8.0/jre/lib/sunrsasign.jar:/opt/jdk1.8.0/jre/lib/jsse.jar:/opt/jdk1.8.0/jre/lib/jce.jar:/opt/jdk1.8.0/jre/lib/charsets.jar:/opt/jdk1.8.0/jre/lib/jfr.jar:/opt/jdk1.8.0/jre/classes, java.vendor=Oracle Corporation, file.separator=/, java.vendor.url.bug=http://bugreport.sun.com/bugreport/, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.cpu.isalist=}
java.runtime.name : Java(TM) SE Runtime Environment
sun.boot.library.path : /opt/jdk1.8.0/jre/lib/arm
java.vm.version : 25.0-b69
java.vm.vendor : Oracle Corporation
java.vendor.url : http://java.oracle.com/
path.separator : :
java.vm.name : Java HotSpot(TM) Client VM
file.encoding.pkg : sun.io
user.country : GB
sun.java.launcher : SUN_STANDARD
sun.os.patch.level : unknown
java.vm.specification.name : Java Virtual Machine Specification
user.dir : /home/pi/worksJava
java.runtime.version : 1.8.0-b128
java.awt.graphicsenv : sun.awt.X11GraphicsEnvironment
java.endorsed.dirs : /opt/jdk1.8.0/jre/lib/endorsed
os.arch : arm
java.io.tmpdir : /tmp
line.separator :
java.vm.specification.vendor : Oracle Corporation
os.name : Linux
sun.jnu.encoding : UTF-8
java.library.path : /usr/java/packages/lib/arm:/lib:/usr/lib
java.specification.name : Java Platform API Specification
java.class.version : 52.0
sun.management.compiler : HotSpot Client Compiler
os.version : 3.10.28+
user.home : /home/pi
sun.arch.abi : gnueabihf
user.timezone : Asia/Hong_Kong
java.awt.printerjob : sun.print.PSPrinterJob
file.encoding : UTF-8
java.specification.version : 1.8
user.name : pi
java.class.path : .
java.vm.specification.version : 1.8
sun.arch.data.model : 32
java.home : /opt/jdk1.8.0/jre
sun.java.command : listProperties
java.specification.vendor : Oracle Corporation
user.language : en
awt.toolkit : sun.awt.X11.XToolkit
java.vm.info : mixed mode
java.version : 1.8.0
java.ext.dirs : /opt/jdk1.8.0/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path : /opt/jdk1.8.0/jre/lib/resources.jar:/opt/jdk1.8.0/jre/lib/rt.jar:/opt/jdk1.8.0/jre/lib/sunrsasign.jar:/opt/jdk1.8.0/jre/lib/jsse.jar:/opt/jdk1.8.0/jre/lib/jce.jar:/opt/jdk1.8.0/jre/lib/charsets.jar:/opt/jdk1.8.0/jre/lib/jfr.jar:/opt/jdk1.8.0/jre/classes
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.cpu.isalist :
No comments:
Post a Comment