chance chance - 1 year ago 197
Java Question

How to find the default JMX port number?

I am running a Java application on Java 6 VM on a remote Windows XP, on which I can run jvisualvm.exe to connect to the running application automatically.

Now I need to connect that application from my local computer, but I don't know the JMX port number of the remote computer. Where can I find it? Or, must I restart that application with some VM parameters to specify the port number?

After reading the question How to find the JMX port in a server, I executed the command on the remote computer

netstat -apn

but got nothing.

Answer Source

By default JMX does not publish on a port unless you specify the arguments from this SO page: How to activate JMX... Are you doing this already?

If you are running you should be able to access any of those system properties to see if they have been set:

if (System.getProperty("") == null) {
    System.out.println("JMX remote is disabled");
} else [
    String portString = System.getProperty("");
    if (portString != null) {
        System.out.println("JMX running on port "
            + Integer.parseInt(portString));

As an aside, my SimpleJMX package allows you to define both the JMX server and the RMI port or set them both to the same port. The above port defined with is actually the RMI port. This tells the client what port the JMX server is running on.