The jcmd command – the small command line utility that does a lot

Since Java 8, the JDK has been coming with the jcmd command, which allows you to execute commands on a local Java instance using the same user/group as the instance you want to check.

The usage of jcmd, although command-based, is quite simple. To understand it, we will first start our quote manager application with the command we saw in Chapter 1, Money – The Quote Manager Application:

mvn clean package embedded-glassfish:run

Now in another console, just execute jcmd. On my system, it will dump what follows:

$ jcmd4981 com.intellij.idea.Main7704 sun.tools.jcmd.JCmd7577 org.codehaus.plexus.classworlds.launcher.Launcher clean package embedded-glassfish:run5180 org.jetbrains.idea.maven.server.RemoteMavenServer ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.