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: 
You can actually get a list of JVMs using the [Attach API](http://docs.oracle.com/javase/8/docs/jdk/api/attach/spec/index.html), without resorting to using `jconsole.jar`.

The following demonstrates getting the list of JVMs running locally, getting some properties, connecting to each via JMX, and getting some further information via that connection.

```
// ...

import com.sun.tools.attach.*;
import javax.management.*;

// ...

    List<VirtualMachineDescriptor> descriptors = VirtualMachine.list();
    for (VirtualMachineDescriptor descriptor : descriptors) {
        System.out.println("Found JVM: " + descriptor.displayName());
        try {
            VirtualMachine vm = VirtualMachine.attach(descriptor);
            String version = vm.getSystemProperties().getProperty("java.runtime.version");
            System.out.println("   Runtime Version: " + version);

            String connectorAddress = vm.getAgentProperties().getProperty("com.sun.management.jmxremote.localConnectorAddress");
            if (connectorAddress == null) {
                vm.startLocalManagementAgent();
                connectorAddress = vm.getAgentProperties().getProperty("com.sun.management.jmxremote.localConnectorAddress");
            }

            JMXServiceURL url = new JMXServiceURL(connectorAddress);
            JMXConnector connector = JMXConnectorFactory.connect(url);
            MBeanServerConnection mbs = connector.getMBeanServerConnection();

            ObjectName threadName = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
            Integer threadCount = (Integer)mbs.getAttribute(threadName, "ThreadCount");
            System.out.println("    Thread count: " + threadCount);
        }
        catch (Exception e) {
            // ...
        }
    }

```

A list of the available `MXBean`s is [here](http://docs.oracle.com/javase/8/docs/api/java/lang/management/package-summary.html). More on JMX in general can be found [here](http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html), which I got from a comment on [another answer](https://stackoverflow.com/a/5200305/565857) to this question. Some code above came from both links.

**Note**: For me at least, I had to add `tools.jar` to the bootstrap classpath for this to run:

```
$ java -Xbootclasspath/a:${JAVA_HOME}/lib/tools.jar -jar <jar>

```
I don't know about Java 6, but I think you can do by running jconsole from the command line.

Also, if you are on a \*nix platform you can issue a command like this this:

```
ps aux | grep java

```

Good luck!