Fundamentals 9 min read

JVM Parameter Types and Hands‑On Experiments

This tutorial explains the three main categories of JVM parameters—standard, X, and XX—demonstrates how to view, modify, and verify them using command‑line tools such as java, jps, and jinfo, and provides step‑by‑step hands‑on labs for each type.

Wukong Talks Architecture
Wukong Talks Architecture
Wukong Talks Architecture
JVM Parameter Types and Hands‑On Experiments

The purpose of this lab is to explain the three major JVM parameter types and demonstrate how to view and set them, which is essential knowledge for JVM tuning.

Standard Parameters

-version – get JDK version

-help – get help information

-showversion – display version and help

Experiment 1 – View Standard Parameters

Run the following commands in the console: java -version Result shows JDK version 1.8.0_131. java -help Displays the help document. java -showversion Shows both version and help.

X Parameters

X Parameter Overview

-Xint – pure interpretation mode

-Xcomp – compile to native code before execution

-XMixed – mixed mode (both compilation and interpretation)

Experiment 2 – View and Configure X Parameters

Check current mode: java -version Switch to interpretation mode: java -Xint -version Switch to compilation‑only mode:

java -Xcomp -version

XX Parameters

XX Parameter Overview

XX parameters come in two forms:

Boolean type: -XX:+SomeFlag (enable) or -XX:-SomeFlag (disable). Example: -XX:-PrintGCDetails disables GC detail output.

Key‑value type: -XX:Key=Value. Example: -XX:MetaspaceSize=2000000 sets metaspace size.

Experiment 3 – Check If a Parameter Is Enabled

Create a long‑running Java program (demoXXparam.java) and run it, then use: jps -l Find the process ID, then query the flag: jinfo -flag PrintGCDetails <pid> The output -XX:-PrintGCDetails indicates the flag is disabled.

Experiment 4 – Enable a Parameter

Terminate the program, then restart it with the flag enabled: java -XX:+PrintGCDetails demoXXparam Now jinfo -flag PrintGCDetails <pid> shows -XX:+PrintGCDetails, meaning the flag is active.

Experiment 5 – Key‑Value Parameter Value

Check metaspace size: jinfo -flag MetaspaceSize <pid> Set metaspace to 128 M: java -XX:MetaspaceSize=128m demoXXparam Verify the new value with the same jinfo command.

Experiment 6 – Set InitialHeapSize and MaxHeapSize

Set initial heap size: java -XX:InitialHeapSize=200m demoXXparam Set maximum heap size:

java -XX:MaxHeapSize=200m demoXXparam

Experiments 7‑10 – List JVM Flags

Print default flags: java -XX:+PrintFlagsInitial -version Print final flags (including user‑defined): java -XX:+PrintFlagsFinal -version Print command‑line flags: java -XX:+PrintCommandLineFlags -version Print all flags of a running process:

jinfo -flags <pid>

Experiment Summary

The lab covered how to view basic, X, and XX JVM parameters, how to modify them, and how to use jps and jinfo to inspect running Java processes. These skills form the foundation for JVM performance tuning.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaJVMperformance tuningcommand-lineJInfojpsJVM Parameters
Wukong Talks Architecture
Written by

Wukong Talks Architecture

Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.