2. Monitor the Java VM with a tool that complies with the JMX specification, such as
JConsole. See Using JConsole.
Local Monitoring and Management
Earlier while starting the Java VM or Java application, you set the following property to
allow the JMX client access to a local Java VM:
com.sun.management.jmxremote
Setting this property registered the Java VM platform's MBeans and published the
remote method invocation (RMI) connector through a private interface. This setting
allows JMX client applications to monitor a local Java platform, that is, a Java VM
running on the same machine as the JMX client.
In the current Java SE platform, it is no longer necessary to set this system property.
Any application that is started on the current Java SE platform supports the Attach
API, and will automatically be made available for local monitoring and management
when needed.
For example, previously, to enable the JMX agent for the Java SE sample application
Notepad
, you would run the following commands:
% cd JDK_HOME/demo/jfc/Notepad
% java -Dcom.sun.management.jmxremote -jar Notepad.jar
In the preceding command,
JDK_HOME
is the directory in which the Java Development
Kit (JDK) is installed. In the current Java SE platform, you have to run the following
command to start
Notepad
.
% java -jar Notepad.jar
After
Notepad
has been started, a JMX client using the Attach API can then enable the
out-of-the-box management agent to monitor and manage the
Notepad
application.
Note:
On Windows platforms, for security reasons, local monitoring and
management is supported only if your default temporary directory is on a file
system that allows the setting of permissions on files and directories (for
example, on a New Technology File System (NTFS) file system). It is not
supported on a File Allocation Table (FAT) file system, which provides
insufficient access controls.
Local Monitoring and Management Using JConsole
Local monitoring with JConsole is useful for development and creating prototypes.
Using JConsole locally is not recommended for production environments, because
JConsole itself consumes significant system resources. Rather, you should use
JConsole on a remote system to isolate it from the platform being monitored.
However, if you do wish to perform local monitoring using JConsole, then you start the
tool by entering
jconsole
in a command shell. When you start
jconsole
without any
arguments, it will automatically detect all local Java applications, and display a dialog
box that enables you to select the application that you want to monitor. Both JConsole
Chapter 2
Enabling the Ready-to-Use Management
2-2