Common JDK Commands for Java Developers
This article introduces essential JDK command‑line tools such as jps, jinfo, jstat, jmap, jhat and jstack, explaining their options, usage examples, and how they help developers monitor, diagnose and troubleshoot Java applications in production environments.
Hello everyone, I'm Duck Blood Noodles. Many developers struggle with JDK commands during interviews or when troubleshooting production issues, especially if they lack hands‑on experience with live environments.
Below is a comprehensive overview of frequently used JDK commands, each illustrated with examples and screenshots.
JDK Common Commands
First, a summary diagram is shown, followed by detailed usage of each command.
JPS
The jps or jps | grep -v Jps command lists all JVM processes on the system, displaying their process IDs (pids). Running man jps reveals five options:
-q: output only the pid
-m: show arguments passed to the main method
-l: display the full main class name
-v: show JVM arguments
-V: output only pid and jar name
Example output is demonstrated with screenshots.
JINFO
After obtaining a JVM pid (e.g., 2528), jinfo 2528 displays detailed JVM information such as version, environment variables, and more. The manual can be consulted via man jinfo .
JSTAT
The jstat tool monitors JVM statistics, for example GC utilization. The command jstat -gcutil 2528 1000 10 prints GC info every second for ten iterations. Adding -h3 inserts a header every three lines.
JMAP
jmap creates a heap dump; for instance jmap -dump:live,format=b,file=dump.bin 2528 generates a binary dump file. The dump can later be analyzed with jhat .
JHAT
Using jhat dump.bin starts a web service on port 7000 to explore the heap dump through a browser.
JSTACK
jstack 2528 produces a thread dump, showing the call stacks of all threads, which helps identify deadlocks, long‑running loops, or resource waits.
Summary
The above JDK commands are essential tools for Java developers to diagnose and resolve runtime issues; mastering them can greatly improve interview performance and real‑world troubleshooting.
Final Note
Join our knowledge community for more Java insights, resources, and discussions.
Full-Stack Internet Architecture
Introducing full-stack Internet architecture technologies centered on Java
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.