My specific question has to do with JMX as used in JDK 1.6: if I am running a Java process using JRE 1.6 with
com.sun.management.jmxremote
I've been working recently to figure out how to enable remote JMX management from java code, without requiring the JVM to have been started with special properties set. The solution I settled on is to start my own private RMI registry -- easy enough -- and to expose the JMX service on that registry. I create my own MBeanServer, then create a new JMXConnectorServer. The JMXConnectorServer is created through a call like
connector = JXMConnectorServerFactory.newJMXConnectorServer(url, null, server);
Where server is the MBeanServer, and url is an instance of JMXServiceURL.
The url is of the form "service:jmx:rmi:///jndi/rmi://localhost:/jmxrmi" where port is the (local) private registry's port number. "jmxrmi" is the standard service name for the JMX service.
After setting this up, and starting the connector, I find that I can connect to it from jconsole using hostname:port.
This entirely addresses my needs; I will be interested to know if anyone sees a flaw in this approach.
Reference: JMX Tutorial, Chap. 3