Operations 8 min read

Master JDK Command-Line Tools for JVM Performance Tuning: A Practical Guide

This guide explores the JDK command‑line utilities located in %JAVA_HOME%\bin, explaining how tools such as jps, jstat, jinfo, jmap, jhat and jstack can be used to monitor JVM processes, analyze performance bottlenecks, inspect memory usage, generate heap dumps, and adjust runtime parameters for more efficient and stable Java applications.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Master JDK Command-Line Tools for JVM Performance Tuning: A Practical Guide

Introduction

This article provides an in‑depth analysis of JDK command‑line tools and demonstrates how to use them for JVM performance tuning. By learning the various utilities supplied with the JDK, readers can monitor JVM runtime status, identify performance bottlenecks, and adjust JVM parameters to improve application stability and efficiency.

The tools are located in the %JAVA_HOME%\bin directory.

JDK bin directory
JDK bin directory

Most of these executables are lightweight wrappers around classes found in %JAVA_HOME%\bin\tools.jar.

Tool Overview

The following commonly used tools are covered:

jps – Lists all currently running HotSpot JVM processes.

jstat – Monitors various runtime metrics such as class loading, memory usage, and garbage collection.

jinfo – Displays and modifies JVM parameters at runtime.

jmap – Generates heap dump snapshots and provides heap information.

jhat – Analyzes heap dump files.

jstack – Produces thread stack snapshots of a running JVM.

jps

Usage example:

public class JpsMain {
  public static void main(String[] args) throws Exception {
    System.out.println(java.util.Arrays.toString(args));
    System.in.read();
  }
}

Run the program with three arguments (a, b, c) and then execute:

jps output
jps output

Common options: -l – Shows full package and class name; for JARs, displays the JAR path. -m – Shows the arguments passed to the JVM at startup. -v – Shows JVM arguments used to start the process. -q – Displays only the process ID.

jstat

Syntax:

jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Parameters: vmid – JVM process ID. interval – Query interval (seconds or milliseconds). count – Number of queries.

Key options: -class – Shows class loading statistics. -compiler – Shows JIT compilation information. -gc – Monitors heap usage and GC times. -gcutil – Similar to -gc but focuses on usage percentages. -gcnew – Monitors young generation GC. -gcold – Monitors old generation GC.

Example: jstat -gc 16480 3s This command reports GC statistics every 3 seconds.

jinfo

Usage: jinfo <option> <pid> Example to display all JVM parameters for process 16480:

jinfo -flag CICompilerCount 16480
jinfo output
jinfo output

jmap

Syntax: jmap [option] <pid> Important options: -dump – Generates a live heap dump (e.g., jmap -dump:live,format=b,file=heap.bin <pid>). -heap – Shows detailed heap information, including GC algorithms and generation sizes. -histo – Displays a histogram of objects in the heap.

jmap -heap output
jmap -heap output

jhat

Usage: jhat <heap-dump-file> After generating a heap dump with jmap -dump, run jhat to start a web service (default port 7000) for interactive analysis.

jhat interface
jhat interface

jstack

Syntax: jstack [option] <pid> Common options: -F – Forces a thread dump when the JVM is unresponsive. -l – Includes lock information. -m – Shows native C/C++ stack frames for native methods.

jstack output
jstack output

Conclusion

By mastering these JDK command‑line utilities—jps, jstat, jinfo, jmap, jhat, and jstack—developers can effectively monitor JVM health, diagnose performance issues, and fine‑tune runtime parameters, leading to more reliable and high‑performing Java applications.

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 tuningJDKcommand-line tools
Spring Full-Stack Practical Cases
Written by

Spring Full-Stack Practical Cases

Full-stack Java development with Vue 2/3 front-end suite; hands-on examples and source code analysis for Spring, Spring Boot 2/3, and Spring Cloud.

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.