0 votes
1 view
in Java by (3.5k points)

How to activate JMX on a JVM for access with jconsole?

1 Answer

0 votes
by (46.1k points)

The relevant documentation can be found here:


Start your program with following code:






For example like this:

java -Dcom.sun.management.jmxremote \

  -Dcom.sun.management.jmxremote.port=9010 \

  -Dcom.sun.management.jmxremote.local.only=false \

  -Dcom.sun.management.jmxremote.authenticate=false \

  -Dcom.sun.management.jmxremote.ssl=false \

  -jar Notepad.jar

-Dcom.sun.management.jmxremote.local.only=false is not necessarily neededbut without it, it doesn't work on Ubuntu. The error would be something like this:

01 Oct 2008 2:16:22 PM sun.rmi.transport. customer .TCPTransport$AcceptLoop executeAcceptLoop

WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=,port=0,localport=37278] throws

java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory only accept connections from clients running on the host where the RMI remote objects have been exported.

    at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:89)

    at sun.rmi.transport. customer .TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:387)

    at sun.rmi.transport. customer .TCPTransport$AcceptLoop.run(TCPTransport.java:359)

    at java.lang.Thread.run(Thread.java:636)

see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6754672

Also be careful with -Dcom.sun.management.jmxremote.authenticate=false which makes access available for anyone, but if you only use it to track the JVM on your local machine it doesn't matter.

In some cases I was not able to reach the server. This was then fixed if I set this parameter as well: -Djava.rmi.server.hostname=

Welcome to Intellipaat Community. Get your technical queries answered by top developers !