JVMList implements JVMListMBean { @Override public List<VMDescriptorDTO> listLocalJVMs() { List<VMDescriptorDTO> rc = new ArrayList<>(); try { List<VirtualMachineDescriptor> processes = VirtualMachine.list(); for (VirtualMachineDescriptor process : processes) { VMDescriptorDTO dto = new VMDescriptorDTO(process); dto.setAgentUrl(agentStatus(dto.getId())); String alias = getVmAlias(process.displayName(), dto.getAgentUrl()); dto.setAlias(alias); if (dto.getAgentUrl() != null) { try { URL url = new URL(dto.getAgentUrl()); dto.setScheme(url.getProtocol()); dto.setHostname(url.getHost()); dto.setPort(url.getPort()); dto.setPath(url.getPath()); } catch (Exception e) { } } rc.add(dto); } } catch (Exception e) { LOG.warn("Failed to get local JVM processes due to: {}", e.getMessage()); throw new RuntimeException("Failed to get local JVM processes due to: " + e.getMessage(), e); } return rc; } JVMList(); void init(); void destroy(); @Override List<VMDescriptorDTO> listLocalJVMs(); @Override void startAgent(String PID); @Override String agentStatus(String PID); @Override String agentVersion(String PID); @Override void stopAgent(String PID);  }
@Test public void test03ListJVMs() { List<VMDescriptorDTO> jvms = getJVMList().listLocalJVMs(); for (VMDescriptorDTO jvm : jvms) { System.out.println("JVM: " + jvm); } }