使用 RMI 以本地模式连接到 JMX(无端口)

Use RMI to connect to JMX in local mode (without a port)

JMX agent docs 解释了在未提供 com.sun.management.jmxremote.port 时存在本地模式。

该文档似乎还暗示这需要临时文件并且只有 JConsole 才能理解。

我想知道以上是否正确,如果正确,如何使用 RMI 连接到代理?

叫做Attach API. Technically, it does use a port, but it does not require the target JVM to have pre-launched a JMX Connector Server. Once connected, the target JVM will launch a new connector server and the JMXServiceURL of that server can be retrieved from the VirtualMachine instance by looking up the agent propertycom.sun.management.jmxremote.localConnectorAddress.