The jconsole command launches
a graphical console tool that enables you to monitor and manage Java
applications on a local or remote machine.
jconsole can attach to any
application that is started with the Java Management Extensions (JMX)
agent. A system property defined on the command line enables the JMX
agent. Once attached, jconsole can be used to display
useful information such as thread usage, memory consumption, and details
about class loading, runtime compilation, and the operating system.
In addition to monitoring, jconsole can be used to dynamically change several parameters in the running
system. For example, the setting of the -verbose:gc option can be changed so that garbage collection
trace output can be dynamically enabled or disabled for a running
application.
To use jconsole:
Start the application
with the -Dcom.sun.management.jmxremote option. This
option sets the com.sun.management.jmxremote system
property, which enables the JMX agent.
Start jconsole with the jconsole command.
When jconsole starts, it shows a screen listing the managed Java VMs on the machine.
The process id (pid) and command line arguments for each Java VM are
displayed. Select one of the Java VMs, and jconsole attaches to it.
The following example shows invocation of jconsole. First the Java application must be started with
the JMX agent enabled:
$ java -Dcom.sun.management.jmxremote -jar Java2Demo.jar &
[1] 13028 |
Now the jconsole tool can be
started on the managed Java VM:
$ /opt/java1.5/bin/jconsole 13028 |
The following figure shows a jconsole screen:
jconsole can also be run remotely.
To learn more about jconsole, including remote
invocation, refer to the following webpage:
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html