DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

VisualVM Extensions

Wayne Adams user avatar by
Wayne Adams
·
Oct. 08, 11 · Interview
Like (0)
Save
Tweet
Share
6.56K Views

Join the DZone community and get the full member experience.

Join For Free

As I mentioned in an earlier post, I noticed recently that the JDK utility VisualVM is extensible, and it was my goal to create a useful extension. I didn't intend to create a "getting started" guide, as there is plenty of information already available, but I keep running into the "out of date tutorial" issue. Having encapsulated some additional information into my earlier post in the setup category, I now find myself having to clear up issues I'm encountering while using NetBeans 7 to actually create an extension. While some of the differences might be traceable to the new version of NetBeans, I think some of them may be due to expected API changes and similar issues.

I'm working through the Creating a "Hello World" Plugin tutorial. I'll basically follow that tutorial here, with changes and observations/tips as needed.

If you followed my earlier post, you already have a new project, as that step was necessary to "seed" the Platform Manager into the clean-install NetBeans 7 Tools menu. If not, just follow Geertjan's steps in his tutorial. My next step was to create the Module Installer. In NetBeans 7, the selection items are slightly different. You still choose "New", then "Other...", then select "Module Development", but the File Type is now called "Installer / Activator" rather than "Module Installer". Further, the description says this installer is frequently not needed. I don't know if that's the case here, so I created one anyway.

The tutorial says to add the "VisualVM-Core" library as a dependency for the project. As you create your "Hello World" application according to the tutorial, you'll quickly learn that you also need to add a dependency on "VisualVM-Application", also, so you may as well do so at the same time.

If you're not fond of "seeing red" in an IDE, you might want to create the Java classes in the reverse order of the tutorial. Also, source listings in the tutorial don't include imports (the downloadable full sample does, of course). If you don't feel like retrieving the full sample, here are the imports for the HelloWorldProvider class:

 import com.sun.tools.visualvm.application.Application;
  import com.sun.tools.visualvm.core.ui.DataSourceView;
  import com.sun.tools.visualvm.core.ui.DataSourceViewProvider;
  import com.sun.tools.visualvm.core.ui.DataSourceViewsManager;

and, in the HelloWorldView class:

  import javax.swing.ImageIcon;
  import com.sun.tools.visualvm.application.Application;
  import com.sun.tools.visualvm.core.ui.DataSourceView;
  import com.sun.tools.visualvm.core.ui.components.DataViewComponent;
  import javax.swing.BorderFactory;
  import javax.swing.JEditorPane;
  import javax.swing.JPanel;
  import org.openide.util.Utilities;

 

From here, right-click on the project and select "Run" and you will get an instance of VisualVM. Selecting an application to monitor will expose your new "Hello World" tab. That was actually quite easy!

Pause for Perspective


What have we just done?

With VisualVM extensions, there are two different paths you can take:

  1. Creating a new tool that you want to make available to VisualVM, a tool that will be available to analyze any Java application.

  2. Providing a plugin for a unique type of application and using VisualVM to expose tooling specific to that application type.


What we have done in this "Hello World" is an example of #1 above, provided in the form of a new tab. If you do this, you aren't likely going to be leveraging anything unique about whatever application you are currently thinking of monitoring -- this version of VisualVM will expose the new tab for any and all Java applications to which it attaches.

Which type you choose will probably depend on what project currently interests you, and your general motivations. For example, it seems every project I work on could really use an application-specific VisualVM plugin. I typically use VisualVM on every project I work on, but I have to admit I don't see a lot of other users (unfortunately, because I think it's a great tool). In a production situation, technical support personnel are usually familiar with a small set of tools specific to their environment. For example, a WLS shop has support staff who are familiar with the WLS console; switching to JBoss in such a shop is a lot more complex than simply convincing someone of the technical virtues of one platform over another. There's a training and support issue, too. Additionally, I don't know of any support staff who use VisualVM.

Much as I'd like to provide a unique plugin for the applications I'm currently involved with, it would be a big investment for something that might not get a lot of adoption (and be useless for almost any other application). So, I probably would be more motivated to build a general-purpose module, or build a module that could be highly configurable for any application.

I have an idea in mind for just such a project; I'll share it at a later date. That way, if I get distracted by the guitar or practicing Portuguese and never get around to doing it, there won't be any 404s from my blog. But if I do get around to it, I'll update this entry just as soon as I do! In the interim, I hope that everyone who sees this will be motivated to add some valuable content to VisualVM. More later.

 

From http://wayne-adams.blogspot.com/2011/10/visualvm-extensions.html

application

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Master Spring Boot 3 With GraalVM Native Image
  • Specification by Example Is Not a Test Framework
  • Strategies for Kubernetes Cluster Administrators: Understanding Pod Scheduling
  • Rust vs Go: Which Is Better?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: