Question: 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? Is there a Java library that can do this?

Answer: 
This, I found out today, is basically what JPS does: simply list the folder **/tmp/hsperfdata\_foo/** where foo is the user running the JVM.

For some unknown reason, sometimes the files there won't be deleted when a JVM is killed.

Here are the links to the source code:

[PerfDataFile.java](http://javasourcecode.org/html/open-source/jdk/jdk-5.0/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataFile.java.html)

[LocalVmManager](http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Modules-sun/jvmstat/sun/jvmstat/perfdata/monitor/protocol/local/LocalVmManager.java.htm)
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](http://download.oracle.com/javase/6/docs/technotes/guides/management/index.html) for the management stuff.
Especially interesting seems the point [Monitoring and Management Using the JMX API](http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html).

(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.)