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
The documentation seems to indicate that the JMX agent uses a local ephemeral port, unless you specify the following property:
com.sun.management.jmxremote.port=portNum
Default ports are avoided because you could have many java applications on one system, and if there was a default port, only one application would be able to be managed! The above configuration property is provided for the express purpose of remote management.
If you must insist on using an ephemeral port, then the URL of the JMX agent should be accessible from within the JVM, through the following system property (although this is likely to be a local address):
com.sun.management.jmxremote.localConnectorAddress
Note: I guess you could always open a socket on a remotely-available address and proxy requests on to the local socket, but using the available option seems far more attractive!