How to monitor a Java program using Jconsole?

前端 未结 3 1692
日久生厌
日久生厌 2021-01-01 17:23

I have written a program to print number from 1 to 200 using 2 threads.

Now I want to monitor this program using JConsole.

Basically I want to learn how to

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 17:56

    You need to enable JMX by adding the following JVM arguments :

    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.port=8484
    -Dcom.sun.management.jmxremote.ssl=false
    

    These parameters will allow any JMX monitoring tool to access and monitoring your application.

    Also i suggest you to use visualVM its more powerful tool. some features for visualVM:

    • Provide a CPU profiling.
    • Provide all info about Threads.
    • Provide the JVM Heap and the memory states.
    • Provide Info about the GC activities.

提交回复
热议问题