Chapter 3
- Java Jconsole
- Windows 8 Upgrade
- Console For Windows 8
- Running Jconsole On Windows
- Overdrive Media Console For Windows 8
Jconsole.exe File Download and Fix For Windows OS, dll File and exe file download Home Articles Enter the file name, and select the appropriate operating system to find the files you need.
The JConsole graphical user interface is a monitoring tool thatcomplies to the Java Management Extensions (JMX) specification.JConsole uses the extensive instrumentation of the Java VirtualMachine (Java VM) to provide information about the performance andresource consumption of applications running on the Javaplatform.
Java Jconsole
Using JConsole, you can investigate the sensitivity of your performance metric by experimenting with the garbage collector parameters. For more information, see Tuning Garbage Collection with the 5.0 HotSpot VM. Monitoring Thread Use. The Threads tab provides information about thread use. Figure 3-8 Threads Tab. Start-> Run-> jconsole.exe and hit/press Enter Select the application which you want to monitor and then click Connect. Alternatively,you can use VisualVM for this purpose as well. Jconsole [ options] [ connection. The command-line options. Connection = pid| host: port| jmxURL. The pid value is the process ID of a local Java Virtual Machine (JVM). The topic of this tutorial is: JConsole download and install.JConsole is a graphical user interface tool that enables you to monitor and manage Java applications and virtual machines on a local or remote machine using the JMX technology. Hi, I Tried to use JConsole to mointor the activity of HP ALM 11.52. I want to monitor ALM in my machine(client machine) using Remote Process connection in.
In the Java SE 6, JConsole has been updated to present the look and feel of theWindows and GNOME desktops (other platforms will present thestandard Java graphical look and feel). The screen capturespresented in this document were taken from an instance of theinterface running on Windows XP.
Starting JConsole
The jconsole executable can be found inJDK_HOME/bin, where JDK_HOME is thedirectory in which the Java Development Kit (JDK) is installed. Ifthis directory is in your system path, you can start JConsole bysimply typing jconsole in a command (shell) prompt.Otherwise, you have to type the full path to the executablefile.
Command Syntax
You can use JConsole to monitor both local applications, namelythose running on the same system as JConsole, as well as remoteapplications, namely those running on other systems.
Note - Using JConsole to monitor a local application isuseful for development and for creating prototypes, but is notrecommended for production environments, because JConsole itselfconsumes significant system resources. Remote monitoring isrecommended to isolate the JConsole application from the platformbeing monitored.
For a complete reference on the syntax of the jconsolecommand, see the manual page for the jconsole command:(Solaris, Linux, or Mac OS X or Windows).
Setting up Local Monitoring
You start JConsole by typing the following command at thecommand line.
When JConsole starts, you will be given a choice of all the Javaapplications that are running locally that JConsole can connectto.
If you want to monitor a specific application, and you know thatapplication's process ID, then you can also start JConsole so thatit connects to that application. This application must be runningwith the same user ID as JConsole. The command syntax to startJConsole for local monitoring of a specific application is thefollowing.
In the command above processID is theapplication's process ID (PID). You can determine an application'sPID in the following ways:
On Solaris, Linux, or Mac OS X systems, you can use the ps command tofind the PID of the java instance that is running.
On Windows systems, you can use the Task Manager to find the PIDof java or javaw.
You can also use the jps command-line utility todetermine PIDs. See the manual page for the jps tool (Solaris, Linux, or Mac OS X or Windows).
For example, if you determined that the process ID of theNotepad application is 2956, then you would start JConsolewith the following command.
Both JConsole and the application must by executed by the sameuser. The management and monitoring system uses the operatingsystem's file permissions. If you do not specify a process ID,JConsole will automatically detect all local Java applications, anddisplay a dialog box that lets you select which one you want tomonitor (see Connecting to a JMX Agent).
For more information, see LocalMonitoring and Management.
Setting up Remote Monitoring
To start JConsole for remote monitoring, you use the followingcommand syntax.
In the command above, hostName is the name ofthe system running the application and portNum isthe port number you specified when you enabled the JMX agent whenyou started the Java VM. For more information, see Remote Monitoring and Management.
If you do not specify a host name/port number combination, thenJConsole will display a connection dialog box (Connecting to a JMX Agent) to enable you to enter ahost name and port number.
Setting up Secure Remote Monitoring
You can also start JConsole so that monitoring will be performedover a connection that is secured using Secure Sockets Layer (SSL).The command to start JConsole with a secure connection is given inRemote Monitoring with JConsole with SSLEnabled in Chapter 2, Monitoring andManagement Using JMX Technology.
Connecting to a JMX Agent
If you start JConsole with arguments specifying a JMX agent toconnect to, it will automatically start monitoring the specifiedJava VM. You can connect to a different host at any time bychoosing Connection | New Connection and entering the necessaryinformation.
Otherwise, if you do not provide any arguments when you startJConsole, the first thing you see is the connection dialog box.This dialog box has two options, allowing connections to eitherLocal or Remote processes.
Dynamic Attach
Under previous releases of the Java SE platform, applicationsthat you wanted to monitor with JConsole needed to be started withthe following option.
However, the version of JConsole provided with the Java SE 6platform can attach to any application that supports the AttachAPI. In other words, any application that is started in the Java SE6 HotSpot VM is detected automatically by JConsole, and does notneed to be started using the above command-line option.
Connecting JConsole to a Local Process
If you start JConsole without providing a specific JMX agent toconnect to, you will see the following dialog window.
Figure 3-1 Creating a Connection to a LocalProcess
The Local Process option lists any Java VMs running on the localsystem that were started with the same user ID as JConsole, alongwith their process ID and their class and/or argument information.To connect JConsole to your application, select the application youwant to monitor, then click the Connect button. The list of localprocesses includes applications running in the following types ofJava VM.
Applications with the management agent enabled. Theseinclude applications on the Java SE 6 platform or on the Java SE 5.0platform that were started with the-Dcom.sun.management.jmxremote option or with the-Dcom.sun.management.jmxremote.port option specified. Inaddition, the list also includes any applications that were startedon the Java SE 6 platform without any management properties butwhich are later attached to by JConsole, which enables themanagement agent at runtime.
Applications that are attachable, with the management agentdisabled. An attachable application supports loading themanagement agent at runtime. Attachable applications includeapplications that are started on the Java SE 6 platform thatsupport the Attach API. Applications which support dynamic attachdo not require the management agent to be started by specifying thecom.sun.management.jmxremote orcom.sun.management.jmxremote.port options at the commandline, and JConsole does not need to connect to the management agentbefore the application is started. If you select this application,you will be informed in a note onscreen that the management agentwill be enabled when the connection is made. In the exampleconnection dialog shown in Figure 3-1,the NetBeans IDE and JConsole itself were both started within aJava SE 6 platform VM. Both appear in normal text, meaning thatJConsole can connect to them. In Figure 3-1, JConsole is selected, and the note isvisible.
Applications that are not attachable, with the managementagent disabled. These include applications started on a Java SE1.4.2 platform or started on a Java SE 5.0 platform without the-Dcom.sun.management.jmxremote orcom.sun.management.jmxremote.port options. Theseapplications appear grayed-out in the table and JConsole cannotconnect to them. In the example connection dialog shown in Figure 3-1, the Anagrams application wasstarted with a Java SE 5.0 platform VM without any of the managementproperties to enable the JMX agent, and consequently shows up ingray and cannot be selected.
Figure 3-2 Attempting to Connect to an Applicationwithout the Management Agent Enabled
In the example connection dialog shown in Figure 3-2, you can see that theAnagrams application has been selected by clicking on it,but the Connect button remains grayed-out and a note has appearedinforming you that the management agent is not enabled for thisprocess. JConsole cannot connect to Anagrams because itwas not started with the correct Java VM or with the correctoptions.
Connecting JConsole to a Remote Process
When the connection dialog opens, you are also given the optionof connecting to a remote process.
Figure 3-3 Creating a Connection to a RemoteProcess
To monitor a process running on a remote Java VM, you mustprovide the following information.
Host name: name of the machine on which the Java VM isrunning.
Port number: the JMX agent port number you specified when youstarted the Java VM.
User name and password: the user name and password to use(required only if monitoring a Java VM through a JMX agent thatrequires password authentication).
For information about setting the port number of the JMX agent,see Enabling the Out-of-the-BoxManagement. For information about user names and passwords, seeUsing Password and Access Files.
To monitor the Java VM that is running JConsole, simply clickConnect, using host localhost and the port 0.
Connecting Using a JMX Service URL
You can also use the Remote Process option to connect to otherJMX agents by specifying their JMX service URL, and the user nameand password. The syntax of a JMX service URL requires that youprovide the transport protocol used to make the connection, as wellas a service access point. The full syntax for a JMX service URL isdescribed in the API documentation forjavax.management.remote.JMXServiceURL.
Figure 3-4 Connecting to a JMX Agent Using the JMXService URL
If the JMX agent uses a connector which is not included in theJava platform, you need to add the connector classes to the classpath when you run the jconsole command, as follows.
In the command above, connector-path is thedirectory or the Java archive (Jar) file containing the connectorclasses that are not included in the JDK, that are to be used byJConsole.
Presenting the JConsole Tabs
Once you have connected JConsole to an application, JConsole iscomposed of six tabs.
Overview: Displays overview information about the Java VMand monitored values.
Memory: Displays information about memory use.
Threads: Displays information about thread use.
Classes: Displays information about class loading.
VM: Displays information about the Java VM.
MBeans: Displays information about MBeans.
You can use the green connection status icon in the upperright-hand corner of JConsole at any time, to disconnect from orreconnect to a running Java VM. You can connect to any number ofrunning Java VMs at a time by selecting Connection thenNew Connection from the drop-down menu.
Viewing Overview Information
The Overview tab displays graphical monitoring information aboutCPU usage, memory usage, thread counts, and the classes loaded inthe Java VM, all in a single screen.
Figure 3-5 Overview Tab
The Overview tab provides an easy way to correlate informationthat was previously only available by switching between multipletabs.
Saving Chart Data
JConsole allows you to save the data presented in the charts ina Comma Separated Values (CSV) file. To save data from a chart,simply right-click on any chart, select Save data as...,and then specify the file in which the data will be saved. You cansave the data from any of the charts displayed in any of JConsole'sdifferent tabs in this way.
The CSV format is commonly usedfor data exchange between spreadsheet applications. The CSV filecan be imported into spreadsheet applications and can be used tocreate diagrams in these applications. The data is presented as twoor more named columns, where the first column represents the timestamps. After importing the file into a spreadsheet application,you will usually need to select the first column and change itsformat to be 'date' or 'date/time' as appropriate.
Monitoring Memory Consumption
The Memory tab provides information about memory consumption andmemory pools.
Figure 3-6 Memory Tab
The Memory tab features a “Perform GC” button thatyou can click to perform garbage collection whenever you want. Thechart shows the memory use of the Java VM over time, for heap andnon-heap memory, as well as for specific memory pools. The memorypools available depend on which version of the Java VM is beingused. For the HotSpot Java VM, the memory pools for serial garbagecollection are the following.
Eden Space (heap): The pool from which memory isinitially allocated for most objects.
Survivor Space (heap): The pool containing objects thathave survived the garbage collection of the Eden space.
Tenured Generation (heap): The pool containing objectsthat have existed for some time in the survivor space.
Permanent Generation (non-heap): The pool containing allthe reflective data of the virtual machine itself, such as classand method objects. With Java VMs that use class data sharing, thisgeneration is divided into read-only and read-write areas.
Code Cache (non-heap): The HotSpot Java VM also includesa code cache, containing memory that is used for compilation andstorage of native code.
You can display different charts for charting the consumption ofthese memory pools by choosing from the options in theChart drop-down menu. Also, clicking on either of the Heapor Non-Heap bar charts in the bottom right-hand corner will switchthe chart displayed. Finally, you can specify the time range overwhich you track memory usage by selecting from the options in theTime Range drop-down menu.
For more information about these memory pools, see Garbage Collection below.
The Details area shows several current memorymetrics:
Used: the amount of memory currently used, including thememory occupied by all objects, both reachable and unreachable.
Committed: the amount of memory guaranteed to beavailable for use by the Java VM. The amount of committed memorymay change over time. The Java virtual machine may release memoryto the system and the amount of committed memory could be less thanthe amount of memory initially allocated at start up. The amount ofcommitted memory will always be greater than or equal to the amountof used memory.
Max: the maximum amount of memory that can be used formemory management. Its value may change or be undefined. A memoryallocation may fail if the Java VM attempts to increase the usedmemory to be greater than committed memory, even if the amount usedis less than or equal to max (for example, when the systemis low on virtual memory).
GC time: the cumulative time spent on garbage collectionand the total number of invocations. It may have multiple rows,each of which represents one garbage collector algorithm used inthe Java VM.
The bar chart on the lower right-hand side shows the memoryconsumed by the memory pools in heap and non-heap memory. The barwill turn red when the memory used exceeds the memory usagethreshold. You can set the memory usage threshold through anattribute of the MemoryMXBean.
Heap and Non-Heap Memory
The Java VM manages two kinds of memory: heap and non-heapmemory, both of which are created when the Java VM starts.
Heap memory is the runtime data area from which the JavaVM allocates memory for all class instances and arrays. The heapmay be of a fixed or variable size. The garbage collector is anautomatic memory management system that reclaims heap memory forobjects.
Non-heap memory includes a method area shared among allthreads and memory required for the internal processing oroptimization for the Java VM. It stores per-class structures suchas a runtime constant pool, field and method data, and the code formethods and constructors. The method area is logically part of theheap but, depending on the implementation, a Java VM may notgarbage collect or compact it. Like the heap memory, the methodarea may be of a fixed or variable size. The memory for the methodarea does not need to be contiguous.
In addition to the method area, a Java VM may require memory forinternal processing or optimization which also belongs to non-heapmemory. For example, the Just-In-Time (JIT) compiler requiresmemory for storing the native machine code translated from the JavaVM code for high performance.
Memory Pools and Memory Managers
Memory pools and memory managers are key aspects of the JavaVM's memory system.
A memory pool represents a memory area that the Java VMmanages. The Java VM has at least one memory pool and it may createor remove memory pools during execution. A memory pool can belongeither to heap or to non-heap memory.
A memory manager manages one or more memory pools. Thegarbage collector is a type of memory manager responsible forreclaiming memory used by unreachable objects. A Java VM may haveone or more memory managers. It may add or remove memory managersduring execution. A memory pool can be managed by more than onememory manager.
Garbage Collection
Garbage collection (GC) is how the Java VM frees memory occupiedby objects that are no longer referenced. It is common to think ofobjects that have active references as being 'alive' andnon-referenced (or unreachable) objects as 'dead.' Garbagecollection is the process of releasing memory used by the deadobjects. The algorithms and parameters used by GC can have dramaticeffects on performance.
The Java HotSpot VM garbage collector uses generational GC.Generational GC takes advantage of the observation that mostprograms conform to the following generalizations.
They create many objects that have short lives, for example,iterators and local variables.
They create some objects that have very long lives, for example,high level persistent objects.
Generational GC divides memory into several generations, andassigns one or more memory pools to each. When a generation uses upits allotted memory, the VM performs a partial GC (also called aminor collection) on that memory pool to reclaim memory used bydead objects. This partial GC is usually much faster than a fullGC.
The Java HotSpot VM defines two generations: the younggeneration (sometimes called the 'nursery') and the old generation.The young generation consists of an 'Eden space' and two 'survivorspaces.' The VM initially assigns all objects to the Eden space,and most objects die there. When it performs a minor GC, the VMmoves any remaining objects from the Eden space to one of thesurvivor spaces. The VM moves objects that live long enough in thesurvivor spaces to the 'tenured' space in the old generation. Whenthe tenured generation fills up, there is a full GC that is oftenmuch slower because it involves all live objects. The permanentgeneration holds all the reflective data of the virtual machineitself, such as class and method objects.
The default arrangement of generations looks something likeFigure 3-7.
Figure 3-7 Generations of Data in GarbageCollection
If the garbage collector has become a bottleneck, you canimprove performance by customizing the generation sizes. UsingJConsole, you can investigate the sensitivity of your performancemetric by experimenting with the garbage collector parameters. Formore information, see TuningGarbage Collection with the 5.0 HotSpot VM.
Monitoring Thread Use
The Threads tab provides information about thread use.
Figure 3-8 Threads Tab
The Threads list in the lower left corner lists all the activethreads. If you enter a string in the Filter field, the Threadslist will show only those threads whose name contains the stringyou enter. Click on the name of a thread in the Threads list todisplay information about that thread to the right, including thethread name, state, and stack trace.
The chart shows the number of live threads over time. Two linesare shown.
Red: peak number of threads
Blue: number of live threads.
The Threading MXBean provides several other useful operationsthat are not covered by the Threads tab.
findMonitorDeadlockedThreads: Detects if any threadsare deadlocked on the object monitor locks. This operation returnsan array of deadlocked thread IDs.
getThreadInfo: Returns the thread information. Thisincludes the name, stack trace, and the monitor lock that thethread is currently blocked on, if any, and which thread is holdingthat lock, as well as thread contention statistics.
getThreadCpuTime: Returns the CPU time consumed by agiven thread
You can access these additional features via the MBeans tab byselecting the Threading MXBean in the MBeans tree. This MXBeanlists all the attributes and operations for accessing threadinginformation in the Java VM being monitored. See Monitoring and Managing MBeans.
Detecting Deadlocked Threads
To check if your application has run into a deadlock (forexample, your application seems to be hanging), deadlocked threadscan be detected by clicking on the 'Detect Deadlock' button. If anydeadlocked threads are detected, these are displayed in a new tabthat appears next to the 'Threads' tab, as shown in Figure 3-9.
Figure 3-9 Deadlocked Threads
The Detect Deadlock button will detect deadlock cycles involvingobject monitors and java.util.concurrent ownablesynchronizers (see the API specification documentation for java.lang.management.LockInfo). Monitoring support forjava.util.concurrent locks has been added in Java SE 6. IfJConsole connects to a Java SE 5.0 VM, the Detect Deadlock mechanismwill only find deadlocks related to object monitors. JConsole willnot show any deadlocks related to ownable synchronizers.
See the API documentation for java.lang.Thread for moreinformation about threads and daemon threads.
Monitoring Class Loading
The Classes tab displays information about class loading.
Figure 3-10 Classes Tab
The chart plots the number of classes loaded over time.
The red line is the total number of classes loaded (includingthose subsequently unloaded).
The blue line is the current number of classes loaded.
The Details section at the bottom of the tab displays the totalnumber of classes loaded since the Java VM started, the numbercurrently loaded and the number unloaded. You can set the tracingof class loading to verbose output by checking the checkbox in thetop right-hand corner.
Viewing VM Information
The VM Summary tab provides information about the Java VM.
Figure 3-11 VM Summary Tab
The information presented in this tab includes thefollowing.
Summary
Uptime: Total amount of time since the Java VM wasstarted.
Process CPU Time: Total amount of CPU time that the JavaVM has consumed since it was started.
Total Compile Time: Total accumulated time spent in JITcompilation. The Java VM determines when JIT compilation occurs.The Hotspot VM uses adaptive compilation, in which the VM launchesan application using a standard interpreter, but then analyzes thecode as it runs to detect performance bottlenecks, or 'hotspots'.
Threads
Live threads: Current number of live daemon threads plusnon-daemon threads.
Peak: Highest number of live threads since Java VMstarted.
Daemon threads: Current number of live daemonthreads.
Total threads started: Total number of threads startedsince Java VM started, including daemon, non-daemon, and terminatedthreads.
Classes
Current classes loaded: Number of classes currentlyloaded into memory.
Total classes loaded: Total number of classes loaded intomemory since the Java VM started, including those that havesubsequently been unloaded.
Total classes unloaded: Number of classes unloaded frommemory since the Java VM started.
Memory
Current heap size: Number of kilobytes currently occupiedby the heap.
Committed memory: Total amount of memory allocated foruse by the heap.
Maximum heap size: Maximum number of kilobytes occupiedby the heap.
Objects pending for finalization: Number of objectspending for finalization.
Garbage collector: Information about garbage collection,including the garbage collector names, number of collectionsperformed, and total time spent performing GC.
Operating System
Total physical memory: Amount of random-access memory(RAM) the operating system has.
Free physical memory: Amount of free RAM available to theoperating system.
Committed virtual memory: Amount of virtual memoryguaranteed to be available to the running process.
Other Information
VM arguments: The input arguments the application passedto the Java VM, not including the arguments to the main method.
Class path: The class path that is used by the systemclass loader to search for class files.
Library path: The list of paths to search when loadinglibraries.
Boot class path: The boot class path is used by thebootstrap class loader to search for class files.
Monitoring and Managing MBeans
The MBeans tab displays information about all the MBeansregistered with the platform MBean server in a generic way. TheMBeans tab allows you to access the full set of the platform MXBeaninstrumentation, including that which is not visible in the othertabs. In addition, you can monitor and manage your application'sMBeans using the MBeans tab.
Figure 3-12 MBeans Tab
The tree on the left shows all the MBeans currently running.When you select an MBean in the tree, its MBeanInfo andits MBean Descriptor are both displayed on the right, and anyattributes, operations or notifications appear in the tree belowit.
All the platform MXBeans and their various operations andattributes are accessible via JConsole's MBeans tab.
Constructing the MBean Tree
By default, the MBeans are displayed in the tree based on theirobject names. The order of key properties specified when the objectnames are created is preserved by JConsole when it adds MBeans tothe MBean tree. The exact key property list that JConsole will useto build the MBean tree will be the one returned by the methodObjectName.getKeyPropertyListString(), with typeas the first key, and j2eeType, if present, as the secondkey.
However, relying on the default order of the ObjectNamekey properties can sometimes lead to unexpected behavior whenJConsole renders the MBean tree. For example, if two object nameshave similar keys but their key order differs, then thecorresponding MBeans will not be created under the same node in theMBean tree.
For example, suppose you create Triangle MBean objectswith the following names.
Windows 8 Upgrade
As far as the JMX technology is concerned, these objects will betreated in exactly the same way. The order of the keys in theobject name makes no difference to the JMX technology. However, ifJConsole connects to these MBeans and the default MBean treerendering is used, then the objectcom.sun.example:type=Triangle,name=2,side=isosceles willend up being created under the Triangle node, in a nodecalled 2, which in turn will contain a sub-node calledisosceles. The other two isosceles triangles,name=1 and name=3, will be grouped together underTriangle in a different node called isosceles, asshown in Figure 3-13.
Figure 3-13 Example of Unexpected MBean TreeRendering
To avoid this problem, you can specify the order in which theMBeans are displayed in the tree by supplying an ordered keyproperty list when you start JConsole at the command line. This isachieved by setting the system propertycom.sun.tools.jconsole.mbeans.keyPropertyList, as shown inthe following command.
The key property list system property takes a comma-separatedlist of keys, in the order of your choosing, wherekey must be a string representing an object namekey or an empty string. If a key specified in the list does notapply to a particular MBean, then that key will be discarded. If anMBean has more keys than the ones specified in the key propertylist, then the key order defined by the value returned byObjectName.getKeyPropertyListString() will be used tocomplete the key order defined by keyPropertyList.Therefore, specifying an empty list of keys simply means thatJConsole will display keys in the order they appear in the MBean'sObjectName.
So, returning to the example of the Triangle MBeanscited above, you could choose to start JConsole specifying thekeyPropertyList system property, so that all your MBeanswill be grouped according to their side key propertyfirst, and their name key property second. To do this, youwould start JConsole with the following command.
Starting JConsole with this system property specified wouldproduce the MBean tree shown in Figure 3-14.
Figure 3-14 Example of MBean Tree Constructed UsingkeyPropertyList
In Figure 3-14, the side keycomes first, followed by the name key. The typekey comes at the end because it was not specified in the keyproperty list, so the MBean tree algorithm applied the original keyorder for the remaining keys. Consequently, the type keyis appended at the end, after the keys which were defined by thekeyPropertyList system property.
According to the object name convention defined by the JMXBest Practices Guidelines, the type key should alwayscome first. So, to respect this convention you should startJConsole with the following system property.
The above command will cause JConsole to render the MBean treefor the Triangle MBeans as shown in Figure 3-15.
Figure 3-15 Example of MBean Tree ConstructedRespecting JMX Best Practices
This is obviously much more comprehensible than the MBean treesshown in Figure 3-13 and Figure 3-14.
MBean Attributes
Selecting the Attributes node displays all the attributes of anMBean. Figure 3-16 shows all theattributes of the Threading platform MXBean.
Figure 3-16 Viewing All MBeanAttributes
Selecting an individual MBean attribute from the tree thendisplays the attribute's value, its MBeanAttributeInfo,and the associated Descriptor in the right pane, as you can see inFigure 3-17.
Figure 3-17 Viewing an Individual MBeanAttribute
You can display additional information about an attribute bydouble-clicking on the attribute value, if it appears in bold text.For example, if you click on the value of theHeapMemoryUsage attribute of the java.lang.MemoryMBean, you will see a chart that looks something like Figure 3-18.
Figure 3-18 Displaying AttributeValues
Double-clicking on numeric attribute values will display a chartthat plots changes in that numeric value. For example,double-clicking on the CollectionTime attribute of theGarbage Collector MBean PS Marksweep will plot the timespent performing garbage collection.
You can also use JConsole to set the values of writableattributes. The value of a writable attribute is displayed in blue.Here you can see the Memory MBean's Verbose attribute.
Figure 3-19 Setting Writable AttributeValues
You can set attributes by clicking on them and then editingthem. For example, to enable or disable the verbose tracing of thegarbage collector in JConsole, select the Memory MXBean in theMBeans tab and set the Verbose attribute to true or false.Similarly, the class loading MXBean also has the Verboseattribute, which can be set to enable or disable class loadingverbose tracing.
MBean Operations
Selecting the Operations node displays all the operations of anMBean. The MBean operations appear as buttons, that you can clickto invoke the operation.Figure 3-20 showsall the operations of the Threading platform MXBean.
Figure 3-20 Viewing All MBeanOperations
Selecting an individual MBean operation in the tree displays thebutton for invoking the MBean operation, and the operation'sMBeanOperationInfo and its Descriptor, as shown inFigure 3-21.
Figure 3-21 Viewing Individual MBeanOperations
MBean Notifications
You can subscribe to receive notifications by selecting theNotifications node in the left-hand tree, and clicking theSubscribe button that appears on the right. The number ofnotifications received is displayed in square brackets, and theNotifications node itself will appear in bold text when newnotifications are received. The notifications of the Memoryplatform MXBean are shown in Figure 3-22.
Figure 3-22 Viewing MBeanNotifications
Selecting an individual MBean notification displays theMBeanNotificationInfo in the right pane, as shown inFigure 3-23.
Figure 3-23 Viewing Individual MBeanNotifications
HotSpot Diagnostic MXBean
Console For Windows 8
JConsole's MBeans tab also allows you to tell the HotSpot VM toperform a heap dump, and to get or set a VM option via theHotSpotDiagnostic MXBean.
Running Jconsole On Windows
Figure 3-24 Viewing the HotSpot DiagnosticMBean
You can perform a heap dump manually by invoking thecom.sun.management.HotSpotDiagnostic MXBean'sdumpHeap operation. In addition, you can specify theHeapDumpOnOutOfMemoryError Java VM option using thesetVMOption operation, so that the VM performs a heap dumpautomatically whenever it receives anOutOfMemoryError.
Creating Custom Tabs
In addition to the existing standard tabs, you can add your owncustom tabs to JConsole, to perform your own monitoring activities.The JConsole plug-in API provides a mechanism by which you can, forexample, add a tab to access your own application's MBeans. TheJConsole plug-in API defines thecom.sun.tools.jconsole.JConsolePlugin abstract class thatyou can extend to build your custom plug-in.
As stated above, your plug-in must extendJConsolePlugin, and implement the JConsolePlugingetTabs and newSwingWorker methods. ThegetTabs method returns either the list of tabs to be addedto JConsole, or an empty list. The newSwingWorker methodreturns the SwingWorker to be responsible for theplug-in's GUI update.
Your plug-in must be provided in a Java archive (JAR) file thatcontains a file namedMETA-INF/services/com.sun.tools.jconsole.JConsolePlugin.This JConsolePlugin file itself contains a list of all thefully-qualified class names of the plug-ins you want to add as newJConsole tabs. JConsole uses the service-provider loading facilityto look up and load the plug-ins. You can have multiple plug-ins,with one entry per plug-in in the JConsolePlugin.
To load the new custom plug-ins into JConsole, start JConsolewith the following command:
In the above command, plugin-path specifies thepaths to the JConsole plug-ins to be looked up. These paths caneither be to directory names or to JAR files, and multiple pathscan be specified, using your platform's standard separatorcharacter.
An example JConsole plug-in is provided with the Java SE 6platform. The JTop application is a JDK demonstration thatshows the CPU usage of all threads running in the application. Thisdemo is useful for identifying threads that have high CPUconsumption, and it has been updated to be used as a JConsoleplug-in as well as a standalone GUI. JTop is bundled withthe Java SE 6 platform, as a demo application. You can run JConsolewith the JTop plug-in by running the following command:
If you connect to this instance of JConsole, you will see thatthe JTop tab has been added, showing CPU usage of thevarious threads running.
Overdrive Media Console For Windows 8
Figure 3-25 Viewing a Custom Plug-inTab