You might need to monitor your java application in order to examine the memory or CPU usage. JConsole is free and available in your JDK from version JDK 5 up.
Jconsole is a JMX-compliant monitoring tool. It uses the extensive JMX instrumentation of the Java virtual machine to provide information on performance and resource consumption of applications running on the Java platform.
The JConsole interface is composed of the following six tabs:
- Summary displays summary information on the JVM and monitored values.
- Memory displays information about memory use.
- Threads displays information about thread use.
- Classes displays information about class loading.
- MBeans displays information about MBeans.
- VM displays information about the JVM.
Java deploying with Tomcat
To enable the jconsole, put following configuration in tomcat/bin/catalina.bat (Windows)
SET JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9033 SET JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
Here, I set the jconsole to use port: 9033
- Start DOS Prompt
- Go to your JDK folder and its bin folder
- On the bin folder, type: jconsole
- You could see a JConsole screen lists some available running JVM application, in my case above
- Service of Eclipse (org.eclipse.equinox.launcher_xxx.jar)
- Tomcat: (org.apache.catalina.startup.Bootstrap start)
- JConsole: (sun.tools.jconsole.JConsole)
- I select my tomcat application
So that each time you do some request in the application, you would see different graphic of Live Threads, CPU Usage, Memory or loaded classes; or you can check each JConsole tab to examine some performance in detail.