### Question:
Jps { public static Map<String, JpsEntity> jps() { Map<String, JpsEntity> map = new HashMap<>(); String s = ExecuteCmd.execute(new String[]{"jps", "-l", "-v"}); String[] line = s != null ? s.split("\n") : new String[0]; for (String aLine : line) { String[] one = aLine.split("\\s+"); if (one[1].contains("sun.tools")){ continue; } if (!one[1].substring(0, 1).equals("-")) { String smallName = one[1].contains(".") ? one[1].substring(one[1].lastIndexOf(".")+1) : one[1]; smallName = smallName.equalsIgnoreCase("jar")? one[1] : smallName; map.put(one[0], new JpsEntity(one[1], smallName, Arrays.stream(one).skip(2).collect(Collectors.toList()))); } else { map.put(one[0], new JpsEntity("NULL","NULL", Arrays.stream(one).skip(1).collect(Collectors.toList()))); } JinfoEntity info = Jinfo.info(one[0]); System.out.println(); System.out.println(info); } return map; }  static Map<String, JpsEntity> jps();  }### Answer:
@Test public void jps() { Map<String, JpsEntity> jps = Jps.jps(); for (Map.Entry entity : jps.entrySet()) { System.out.println(entity.getKey() + " " + entity.getValue()); } }
@Test public void jstat() throws Exception { Map<String, JpsEntity> jps = Jps.jps(); for (Map.Entry entity : jps.entrySet()) { System.out.println(entity.getKey() + " " + entity.getValue()); } Object[] s = jps.keySet().toArray(); for (Object value : s) { System.out.println("进程ID：" + value.toString()); List<KVEntity> jstat = Jstat.jstatClass(value.toString()); jstat.forEach((t) -> System.out.println(t.getKey() + ":" + t.getValue())); JstackEntity jstatk = Jstack.jstack(value.toString()); System.out.println(jstatk); } }