How to connect to a java program on localhost jvm using JMX?

后端 未结 5 1637
孤独总比滥情好
孤独总比滥情好 2020-12-04 08:23

I should connect to a java program on localhost jvm using JMX. In other words I want to develop a JMX client to config a java program on localhost.

  • Don\'t r

5条回答
  •  萌比男神i
    2020-12-04 09:06

    To clarify, if you are only interested in getting local JMX stats, you don't need to use the remote api. Just use java.lang.management.ManagementFactory:

    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    memoryMXBean.getHeapMemoryUsage().getMax();
    ...
    
    List beans = ManagementFactory.getMemoryPoolMXBeans();
    ...
    

提交回复
热议问题