Week 87 — What is the purpose of the `jcmd` tool?

Question of the Week #87
What is the purpose of the jcmd tool?
2 Replies
Eric McIntyre
Eric McIntyre4mo ago
jcmd is a program included in the JDK that allows sending diagnostic commands to running Java applications. When running jcmd, it lists all cuurrently running Java applications and their process ID. This process ID can be used to send commands to the application using jcmd <process ID> <command>. For example, the command GC.heap_info can be executed using jcmd <process ID> GC.heap_info and prints some information about how much of the Java heap space is actually used. Similarly, it is possible to create a heap dump using GC.heap_dump which requires an additional argument with the location of where to store it: jcmd <process ID> <filename>.hprof. Many of these commands like VM.uptime (shows the time the JVM is running), VM.version (displays the Java version), VM.system_properties (lists system properties), VM.classes (lists loaded classes) or VM.events (print JVM event logs) can be used to get information about a running application.
📖 Sample answer from dan1st
Eric McIntyre
Eric McIntyre4mo ago
it's a utility to send diagnostic command requests to a running Java Virtual Machine
Submission from denyaar
Want results from more Discord servers?
Add your server