Launching JConsole as an External Tool From JDeveloper

I find JConsole to be a useful tool, particularly for MBean browsing, but frankly getting the correct command line arguments to get it to connect correctly to my WebLogic instances is a bit of a pain. I always have to go and look it up. - generally from here. However, setting all those paths is tedious. Given that I'm usually working in an environment where my JDeveloper, and the WebLogic servers I'm using JConsole on, are matched from a version perspective I can get JDeveloper's external tools capability to do the lifting.

Very simple this. Just choose Tools > External Tools from the menu and press New.  Then run through the wizard:

  1. Type is External Program
  2. Program Options > Program Executable = jconsole 
  3. Program Options > Arguments =  (All on one line of course, reformatted here for readability)
 -J-Djava.class.path=${java.path}/lib/jconsole.jar:
                     ${java.path}/lib/tools.jar:
                     ${prop:name=weblogic.home}/lib/wljmxclient.jar 
 -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote 

And that's it.  JDeveloper helpfully substitutes both the Java location and the WebLogic location for us saving all that hunting around.  

Tip

 Thanks to Torsten Kleiber who discovered and followed up on the twist of ${java.path} not expanding correctly (or rather expanding to null). Before running the tool command with the macro make sure that you have a project open and selected as the actual java path is obtained in the context of the JRE version used by the selected project. (Project Properties > Libraries and Classpath > Java SE Version)


Comments:

Hi!

I tried this on windows 7 with JDeveloper 11.1.2.4(have replace path separator and slash with backslash), but I get following:
Count not find the main class: sun.tools.jconsole.JConsole. Program will exit.

The message pane, shows that ${java.path} is not expanded on my side:

C:\Oracle\JDev111240\jdk160_24\bin\jconsole.exe -J-Djava.class.path=\lib\jconsole.jar;\lib\tools.jar;../../../wlserver_10.3/server\lib\wljmxclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
java.lang.NoClassDefFoundError: sun/tools/jconsole/JConsole
Caused by: java.lang.ClassNotFoundException: sun.tools.jconsole.JConsole
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:305)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
Exception in thread "main"

After replacing ${java.path} with C:\Oracle\JDev111240\jdk160_24 jconsole comes up.
Is this a bug, that ${java.path} is not set on windows?

Kind regards

Posted by Torsten Kleiber on June 14, 2013 at 10:02 PM BST #

java.path is one of the supported macros so yes you should log and SR if it's not on your platform

Posted by Duncan on June 18, 2013 at 12:34 PM BST #

Hi!

With SR we found out, that the java.path comes from the j2se library version of the project, which has the focus.

I have tested the call without applications/projects opened.
I thought, that in this case the jre is used, in which jdeveloper itself runs.

Not very intuitive but now I know it.

But this leads me to another question: If I use another j2se outside from JDeveloper in my project, must the jconsole match to this j2se? Should the executable set to ${java.path}\bin\jconsole.exe on windows and ${java.path}/bin/jconsole on linux?

Kind regards

Posted by Torsten Kleiber on June 20, 2013 at 06:57 AM BST #

Well imp[licitly JConsole is intended to connect to multiple VMs both local and remote so I assume that there must be some flexibility in the versions it can work with. However, you'd best consult the JConsole doc on this to be sure

Posted by Duncan on June 20, 2013 at 08:13 AM BST #

Post a Comment:
Comments are closed for this entry.
About

Hawaii, Yes! Duncan has been around Oracle technology way too long but occasionally has interesting things to say. He works in the Development Tools Division at Oracle, but you guessed that right? In his spare time he contributes to the Hudson CI Server Project at Eclipse
Follow DuncanMills on Twitter

Note that comments on this blog are moderated so (1) There may be a delay before it gets published (2) I reserve the right to ignore silly questions and comment spam is not tolerated - it gets deleted so don't even bother, we all have better things to do with our lives.
However, don't be put off, I want to hear what you have to say!

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today