List of running JVMs on the localhost

后端 未结 8 1365
慢半拍i
慢半拍i 2020-12-24 15:57

How to get in Java 6+ the list of running JVMs on the localhost and their specs (i.e. Java version, running threads, etc.)?

Does the Java API provide such features?

8条回答
  •  我在风中等你
    2020-12-24 16:07

    Additionally to jps there is the jstack tool, which can print out the stack trace of any java process. The start of its output contains the VM version, then comes a list of threads with their stack traces.

    I think all three of jps, jstack and jconsole are implemented based on the Java Management Beans API in javax.management.* and java.lang.management, so look there for more information on how to do this in your own program.


    Edit: Here is the documentation index for the management stuff. Especially interesting seems the point Monitoring and Management Using the JMX API.

    (And yes, it works not only for the own VM, also for other ones on the same system, and even for ones on remote systems if they expose the right interface.)

提交回复
热议问题