質問

Imagine that: Two java projects are work on JDK1.5 and JDK1.6 Two are work on JDK 1.7. How to get the running jvm names, pids and projects name works on it.

the result should LOOKS LIKE:

pid 1234, projec_tname prj1, java_version JDK1.6

pid 4354, projec_tname prj2, java_version JDK1.5

pid 6234, projec_tname prj3, java_version JDK1.7

pid 9034, projec_tname prj4, java_version JDK1.7

Solution in Is there a Java library that searches for JVMs on the current machine? is find JDKs in current machine which not running. It is not helped for my question. Any ideas?

役に立ちましたか?

解決

You are looking for this API: http://docs.oracle.com/javase/7/docs/jdk/api/attach/spec/

You have to add the tools.jar to your classpath.

This is the method to start with: VirtualMachine.list()

The id()s are provider specific but it’s usually a process id.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top