JVM and OS System Properties

This section provides a tutorial example on how to list all properties from the JVM and the OS that are accessible by your Java application.

Java application programs are executed inside a Java Virtual Machine (JVM), which is in turn executed inside an Operating System (OS). From the Java application program point of view, the JVM, together with the OS, represents the computer system. The properties of the JVM and the OS are all called system properties.

A Java application program can:

Here is an example program that displays the values of all available system properties:

/* SysProperties.java
 - Copyright (c) 2014, HerongYang.com, All Rights Reserved.
 */
import java.util.*;
public class SysProperties {
   public static void main(String[] a) {
      Properties sysProps = System.getProperties();
      sysProps.list(System.out);
   }
}

Output:

-- listing properties --
sun.desktop=windows
awt.toolkit=sun.awt.windows.WToolkit
java.specification.version=10
file.encoding.pkg=sun.io
sun.cpu.isalist=amd64
sun.jnu.encoding=Cp1252
java.class.path=.
java.vm.vendor="Oracle Corporation"
sun.arch.data.model=64
user.variant=
java.vendor.url=http://java.oracle.com/
user.timezone=
os.name=Windows 7
java.vm.specification.version=10
sun.java.launcher=SUN_STANDARD
user.country=US
sun.boot.library.path=C:\Progra~1\java\jdk-10.0.1\bin
sun.java.command=SysProperties
jdk.debug=release
sun.cpu.endian=little
user.home=C:\Users\herong
user.language=en
sun.stderr.encoding=cp437
java.specification.vendor=Oracle Corporation
java.version.date=2018-04-17
java.home=C:\Progra~1\java\jdk-10.0.1
file.separator=\
java.vm.compressedOopsMode=32-bit
line.separator=

java.specification.name=Java Platform API Specification
java.vm.specification.vendor=Oracle Corporation
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
user.script=
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=10.0.1+10
user.name=herong
path.separator=;
os.version=6.1
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=Cp1252
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vendor.version=18.3
java.vendor.url.bug=http://bugreport.java.com/bugreport/
java.io.tmpdir=C:\Users\herong\AppData\Local\Temp\
java.version=10.0.1
user.dir=C:\herong
os.arch=amd64
java.vm.specification.name=Java Virtual Machine Specification
java.awt.printerjob=sun.awt.windows.WPrinterJob
sun.os.patch.level=Service Pack 1
java.library.path=C:\Progra~1\java\jdk-10.0.1\bin;C:\wi...
java.vendor=Oracle Corporation
java.vm.info=mixed mode
java.vm.version=10.0.1+10
sun.io.unicode.encoding=UnicodeLittle
java.class.version=54.0

Note that:

Last update: 2018.

Table of Contents

 About This Book

 JDK - Java Development Kit

 Execution Process, Entry Point, Input and Output

 Primitive Data Types and Literals

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

 Reference Data Types and Variables

 StringBuffer - The String Buffer Class

System Properties and Runtime Object Methods

JVM and OS System Properties

 System.setProperty() - Setting Your Own Properties

 Runtime.getRuntime() - Getting the Runtime Object

 freeMemory() - Getting JVM Free Memory Information

 Calculating Memory Usage of an Array

 exec() - Executing Operating System Commands

 Generic Classes and Parameterized Types

 Generic Methods and Type Inference

 Lambda Expressions and Method References

 Java Modules - Java Package Aggregation

 Execution Threads and Multi-Threading Java Programs

 ThreadGroup Class and "system" ThreadGroup Tree

 Synchronization Technique and Synchronized Code Blocks

 Deadlock Condition Example Programs

 Garbage Collection and the gc() Method

 Outdated Tutorials

 References

 Full Version in PDF/EPUB