Java tools to know what my application is doing
Two critical factors are directly linked to performance when you take an application as a black box:
- Memory usage: If too much memory is consumed, it can slow down the application or even make it dysfunctional
- CPU time: If an operation is too slow, it will consume a lot of CPU cycles and impact the overall performance
Without too much external tooling (except the Java Development Kit (JDK) and/or operating system tools), you can easily extract a lot of information and start working on the performance.
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...