wood burning stoves
The moose likes JBoss/WildFly and the fly likes Using of attach api in Java 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Using of attach api in Java 5" Watch "Using of attach api in Java 5" New topic

Using of attach api in Java 5

Aliaksei Stasheuski

Joined: Apr 08, 2011
Posts: 14
Hello to everyone! I've recently started writing my own tool(like twiddle) for collecting Mbeans attributes from JBoss server. I'd like it to work in the same manner a Jconsole does. The code is below:

It works in the Java 6 as expected.But the problem is that "VirtualMachine" Class isn't available through the Java 5. Have anybody got any suggestions how to make it work in the Java 5. Thank in advance!
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Where did you find the VirtualMachine class? I didn't see that in the javadocs for Java SE 6.

Look for jmx mbean tutorial. There is a really complicated URL that you can use to connect to the JMX manager for any Java app. This might also give some hints: http://community.jboss.org/thread/52375#168437

JBoss In Action
Aliaksei Stasheuski

Joined: Apr 08, 2011
Posts: 14
Thank you for reply! But in the jdk 1.6 the definitelly is such class in the tool.jar archive. which is situated in the lib folder of Java_Home. And what concerns the links you've provided, well it really work and I had it done before your reply. But I need to make in in the way like JConsole does, not through the rmi(I just want to watch MBeans in the locally running machines). The good news is that I've recently found the article I need:


But I actually haven't started to develop the client in such a way. cause I've been installing all the applications on my test environment I need. I'll give you a reply, when I will finish the application.

May be it will happen to be usefull for you too!
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

The com.sun.tools.attach.VirtualMachine is a Sun Java implementation specific class and will not work with other vendors of Java.

[My Blog] [JavaRanch Journal]
Aliaksei Stasheuski

Joined: Apr 08, 2011
Posts: 14
Hello to everybody. I promised to post a reply. when all will be finished. The method. I've proposed in the last post really works, but it needs -Dcom.sun.management.jmxremote to be added to the start configuration of the VM. But It didn't solve the issue in my situation. cause i'm not able to change any cnfiguration on a production server and need to write a request(
I agree. Here's the link: http://aspose.com/file-tools
subject: Using of attach api in Java 5
It's not a secret anymore!