To open the JMX port on the remote JVM, you must enter the port number to use for the JMX RMI connection. Be sure to specify an unused port number. From a command line, go to the bin directory in the <JRE_HOME> directory that contains the Java Runtime Environment (JRE) implementation, for example jre/bin.
The default port for secure JMX access is 9875 and the default username and password are admin and springsource .
The RMI registry tells JMX clients where to find the JMX RMI server port; information can be obtained under key jmxrmi . The RMI registry port is generally known as it is set through system properties at JVM startup.
If you know the process number you can use netstat to find what ports the program is listening on with something like
$ netstat -apn | grep <proc num>
The conventional port for JMX listeners is 1099.
I know it's an old post. You can also get the details from System:
String jmx1 = System.getProperty("com.sun.management.jmxremote");
String jmx2 = System.getProperty("com.sun.management.jmxremote.port");
String jmx3 = System.getProperty("com.sun.management.jmxremote.authenticate");
String jmx4 = System.getProperty("com.sun.management.jmxremote.ssl");
String jmx5 = System.getProperty("java.rmi.server.hostname");
You can also manually set the port from the JVM commandline settings, e.g:
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=1616
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
You can programmatically access the JVM arguments like so:
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
...
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = RuntimemxBean.getInputArguments();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With