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) 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 --
java.specification.version=17
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=https://java.oracle.com/
java.vm.specification.version=17
os.name=Windows 10
sun.java.launcher=SUN_STANDARD
user.country=US
sun.boot.library.path=C:\Progra~1\java\jdk-17.0.1\bin
sun.java.command=jdk.compiler/com.sun.tools.javac.laun...
jdk.debug=release
sun.cpu.endian=little
user.home=C:\Users\herong
user.language=en
sun.stderr.encoding=ms936
java.specification.vendor=Oracle Corporation
java.version.date=2021-10-19
java.home=C:\Progra~1\java\jdk-17.0.1
file.separator=\
java.vm.compressedOopsMode=32-bit
line.separator=

sun.stdout.encoding=ms936
java.vm.specification.vendor=Oracle Corporation
java.specification.name=Java Platform API Specification
jdk.module.main.class=com.sun.tools.javac.launcher.Main
user.script=
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=17.0.1+12-LTS-39
user.name=herong

jdk.launcher.sourcefile=C:\herong\SysProperties.java
path.separator=;
os.version=10.0
java.runtime.name=Java(TM) SE Runtime Environment
file.encoding=Cp1252
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vendor.url.bug=https://bugreport.java.com/bugreport/
java.io.tmpdir=C:\Users\herong\AppData\Local\Temp\
java.version=17.0.1
user.dir=C:\herong
os.arch=amd64
java.vm.specification.name=Java Virtual Machine Specification
sun.os.patch.level=
native.encoding=Cp1252
java.library.path=C:\Progra~1\java\jdk-17.0.1\bin;C:\Wi...
java.vm.info=mixed mode, sharing
java.vendor=Oracle Corporation
java.vm.version=17.0.1+12-LTS-39
sun.io.unicode.encoding=UnicodeLittle
java.class.version=61.0

Note that:

Table of Contents

 About This Book

 JDK - Java Development Kit

 Execution Process, Entry Point, Input and Output

 Primitive Data Types and Literals

 Control Flow Statements

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

 Reference Data Types and Variables

 Enum Types and Enum Constants

 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

 Assert Statements and -ea" Option

 Annotation Statements and Declarations

 Java Related Terminologies

 Archived Tutorials

 References

 Full Version in PDF/EPUB