Home  >  Article  >  Java  >  How do I enable remote JMX access to a JVM using JConsole?

How do I enable remote JMX access to a JVM using JConsole?

Linda Hamilton
Linda HamiltonOriginal
2024-10-28 02:11:30413browse

How do I enable remote JMX access to a JVM using JConsole?

Activating JMX on JVM for Access via JConsole

To enable remote JMX access to a Java Virtual Machine (JVM), you need to activate JMX and set appropriate command-line arguments. Here's how you can do it:

Refer to the official documentation at http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html for full details.

Command-Line Arguments:

Start your JVM with the following parameters:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.rmi.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

For example:

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

Note:

  • The -Dcom.sun.management.jmxremote.local.only=false argument is not strictly necessary but is recommended for Ubuntu compatibility.
  • Exercise caution with -Dcom.sun.management.jmxremote.authenticate=false, as it makes access available to anyone. If you're using JMX only on your local machine, this setting may not be an issue.

Additional Tip:

If you encounter connection issues, try setting the following parameter as well:

-Djava.rmi.server.hostname=127.0.0.1

The above is the detailed content of How do I enable remote JMX access to a JVM using JConsole?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn