How do I get the VM information presented in JConsole?
Starting JConsole, selecing a process and then and heading over to VM Summary, one can see a lot of VM information, such as:
- Number of live threads
- Number of current classes loaded
- Compilation time
- Current heap size 开发者_开发技巧
- Total threads started
Is there I can access that information inside a Java application? If so, how?
Update: Here is an image http://download.oracle.com/javase/1.5.0/docs/guide/management/images/summarytab.jpg
The name of the beast is "Java Management Extension (JMX)".
Here is a "Getting Started" overview from oracle. You'll have to implement a JMX Manager to read the published internals from the JVM or from other instrumented applications.
http://www.java2s.com/Code/Java/Development-Class/ExampleofusingthejavalangmanagementAPItosortthreadsbyCPUusage.htm
enjoy
精彩评论