Geertjan's Blog

  • March 1, 2008

Getting Started Extending VisualVM (Part 5)

Geertjan Wielenga
Product Manager
Update on 30 May 2008: The code and steps in this blog entry have been updated to reflect the VisualVM 1.0 APIs. If you want to download the complete sources of the sample discussed here, get the VisualVM Sample Collection from the Plugin Portal.

Until now, we've only dealt with applications in the context of VisualVM. But applications are only one source of data for VisualVM. There are a few others, one of which is "Host". That is a class that provides the common interface for data sources that represent a localhost or remote host. In the same way as you can extend the Application view, by adding new tabs similar to the "Overview" tab and the "Monitor" tab, you can also extend the Host view. Here you see a new tab in the Host view, called "Hello World":

And here is all the code. First, here's the factory class that will create our tab in the Host view:

import com.sun.tools.visualvm.core.ui.DataSourceView;
import com.sun.tools.visualvm.core.ui.DataSourceViewProvider;
import com.sun.tools.visualvm.core.ui.DataSourceViewsManager;
import com.sun.tools.visualvm.host.Host;
public class DemoViewProvider extends DataSourceViewProvider<Host> {
private static DataSourceViewProvider instance = new DemoViewProvider();
public boolean supportsViewFor(Host host) {
//Always shown:
return true;
public synchronized DataSourceView createView(final Host host) {
return new DemoView(host);
static void initialize() {
DataSourceViewsManager.sharedInstance().addViewProvider(instance, Host.class);
static void unregister() {

Take note of the fact that above we refer to the "Host.class", instead of the "Application.class", as was done previously. Also, we are implementing DataSourceViewProvider<Host>, instead of DataSourceViewProvider<Application>. The view that is created is the same as before, except that the Host class is received instead of the Application class:

import com.sun.tools.visualvm.core.ui.DataSourceView;
import com.sun.tools.visualvm.core.ui.components.DataViewComponent;
import com.sun.tools.visualvm.host.Host;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import org.openide.util.Utilities;
public class DemoView extends DataSourceView {
private DataViewComponent dvc;
private static final String IMAGE_PATH =
"com/sun/tools/visualvm/coredump/resources/coredump.png"; // NOI18N
public DemoView(Host host) {
super(host, "Hello World",
new ImageIcon(Utilities.loadImage(IMAGE_PATH, true)).
getImage(), 60, false);
protected DataViewComponent createComponent() {
//Data area for master view:
JEditorPane generalDataArea = new JEditorPane();
generalDataArea.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));
//Panel, which we'll reuse in all four of our detail views for this sample:
JPanel panel = new JPanel();
//Master view:
DataViewComponent.MasterView masterView = new
DataViewComponent.MasterView("Demo Overview", null, generalDataArea);
//Configuration of master view:
DataViewComponent.MasterViewConfiguration masterConfiguration =
new DataViewComponent.MasterViewConfiguration(false);
//Add the master view and configuration view to the component:
dvc = new DataViewComponent(masterView, masterConfiguration);
//Add detail views to the component:
dvc.addDetailsView(new DataViewComponent.DetailsView(
"Demo Details", null, 10, panel, null), DataViewComponent.TOP_LEFT);
return dvc;

Finally, initialize the factory, in an Installer class, created and registered via a wizard in the IDE:

public class Installer extends ModuleInstall {
public void restored() {
public void uninstalled() {

And that's how you can extend the Host view in VisualVM. The same principle would apply to creating new views for other data sources too.

Update on 30 May 2008: The code and steps in this blog entry have been updated to reflect the VisualVM 1.0 APIs. If you want to download the complete sources of the sample discussed here, get the VisualVM Sample Collection from the Plugin Portal.

Join the discussion

Comments ( 3 )
  • guest Saturday, January 31, 2009

    Hi Geertjan

    I wanted to install the VisualVM plugins in NetBeans 6.5, but the versions currently in the Plugin Portal say

    "Some plugins require plugin TAX Library to be installed.

    The plugin TAX Library is requested in implementation version 4."

    I can't find any reference to the TAX library in the plugin library, etc. Google indicates this might be an XML library but I can't find any downloads for it.



  • guest Sunday, December 20, 2009

    I get the same TAX library issue while trying to install ApplicationType module. I'm using Netbeans 6.7.1 and I'm planning to upgrade to 6.8 to see if its solved.

    Does anyone know what the issue is?


  • Geertjan Sunday, December 20, 2009

    The sample was created for NetBeans IDE 6.1, the instructions clearly state that...

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.