Search code examples
javajmxlanjvisualvm

How can I profile a Java application running on my LAN?


I am trying to profile a Java application running on my LAN from JVisualVM.

However, when I start my program with arguments like:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=9000
-Dcom.sun.management.jmxremote.ssl=false

I am unable to connect through JVisualVM, with JMX or jstatd.

9000 is forwarded, of course, and the server uses Ubuntu.


Solution

  • By default, JMX will open another random port besides the one specified with -Dcom.sun.management.jmxremote.port. Since Java 7u25, you can set this port to a fixed value:

    -Dcom.sun.management.jmxremote.rmi.port=1234
    

    You may set it to the same port as -Dcom.sun.management.jmxremote.port. See this answer for details.

    If you are still having problems with the connection, try debugging it with JConsole. See the answers to this question for details.