Get the system properties from RuntimeMXBean in Java

Java 8Object Oriented ProgrammingProgramming

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine.

RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();

To get the system properties, use the getSystemProperties() method −

System.out.println("System properties from RuntimeMXBean:\n\n "+runtimeMX.getSystemProperties());

The following is an example −

Example

 Live Demo

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Date;
public class Demo {
   public static void main(String args[]) throws Exception {
      RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();
      System.out.println("System properties from RuntimeMXBean:\n\n "+runtimeMX.getSystemProperties());
   }
}

Output

System properties from RuntimeMXBean:
{awt.toolkit=sun.awt.X11.XToolkit, file.encoding.pkg=sun.io, java.specification.version=1.8,
sun.cpu.isalist=, sun.jnu.encoding=UTF-8,
java.class.path=/home/cg/root/GNUstep/Library/Libraries/Java:/usr/GNUstep/Local/Library/Libraries/Java:/usr/G
NUstep/System/Library/Libraries/Java::/usr/share/java/mysql-connector-
java.jar:.:/var/www/html/lib:/var/www/html/lib/dom4j-1.6.jar:/var/www/html/lib/guava-
18.0.jar:/var/www/html/lib/jackson-all.jar:/var/www/html/lib/jaxen-
1.1.4.jar:/var/www/html/lib/jcommon.jar:/var/www/html/lib/jdom2-
2.0.5.jar:/var/www/html/lib/jfreechart.jar:/var/www/html/lib/junit-4.12.jar:/var/www/html/lib/spymemcached-
2.10.3.jar:/var/www/html/lib/stax-1.2.0.jar:/var/www/html/lib/xstream-1.4.7.jar:/var/www/html/lib/gson-
2.3.1.jar:/var/www/html/lib/hamcrest-core-1.3.jar, java.vm.vendor=Oracle Corporation, sun.arch.data.model=64,
java.vendor.url=http://java.oracle.com/, user.timezone=, os.name=Linux, java.vm.specification.version=1.8,
user.country=US, sun.java.launcher=SUN_STANDARD, sun.boot.library.path=/usr/lib/jvm/java-1.8.0-openjdk-
1.8.0.141-1.b16.fc26.x86_64/jre/lib/amd64, sun.java.command=Demo, sun.cpu.endian=little, user.home=?,
user.language=en, java.specification.vendor=Oracle Corporation, java.home=/usr/lib/jvm/java-1.8.0-openjdk-
1.8.0.141-1.b16.fc26.x86_64/jre, file.separator=/, line.separator=
,
java.vm.specification.vendor=Oracle Corporation, java.specification.name=Java Platform API Specification,
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, sun.boot.class.path=/usr/lib/jvm/java-1.8.0-openjdk-
1.8.0.141-1.b16.fc26.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.fc26.x86_64/jre/classes,
sun.management.compiler=HotSpot 64-Bit Tiered Compilers, java.runtime.version=1.8.0_141-b16, user.name=?,
path.separator=:, os.version=3.10.0-862.9.1.el7.x86_64, java.endorsed.dirs=/usr/lib/jvm/java-1.8.0-openjdk-
1.8.0.141-1.b16.fc26.x86_64/jre/lib/endorsed, java.runtime.name=OpenJDK Runtime Environment,
file.encoding=UTF-8, java.vm.name=OpenJDK 64-Bit Server VM,
java.vendor.url.bug=http://bugreport.sun.com/bugreport/, java.io.tmpdir=/tmp, java.version=1.8.0_141,
user.dir=/home/cg/root/5856284, os.arch=amd64, java.vm.specification.name=Java Virtual Machine Specification,
java.awt.printerjob=sun.print.PSPrinterJob, sun.os.patch.level=unknown,
java.library.path=/home/cg/root/GNUstep/Library/Libraries:/usr/GNUstep/Local/Library/Libraries:/usr/GNUstep/S
ystem/Library/Libraries:/usr/local/lib:/usr/lib:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib, java.vm.info=mixed mode, java.vendor=Oracle Corporation, java.vm.version=25.141-b16,
java.ext.dirs=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-
1.b16.fc26.x86_64/jre/lib/ext:/usr/java/packages/lib/ext, sun.io.unicode.encoding=UnicodeLittle,
java.class.version=52.0}
raja
Published on 26-Dec-2018 11:18:09
Advertisements