加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 显示VisualVM等每个可用JVM的主类名

发布时间:2020-12-15 08:39:51 所属栏目:Java 来源:网络整理
导读:VisualVM做得非常好,每个完整的主类名都显示在左侧栏导航中.这些名字是如何检索的? Attach API为所有正在运行的JVM提供显示名称,但是,某些显示名称看起来有点膨胀,例如 Eclipse: C:Program FilesEclipseplugins/org.eclipse.equinox.launcher_1.1.0.v20
VisualVM做得非常好,每个完整的主类名都显示在左侧栏导航中.这些名字是如何检索的? Attach API为所有正在运行的JVM提供显示名称,但是,某些显示名称看起来有点膨胀,例如 Eclipse:

C:Program FilesEclipseplugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar -os win32 -ws win32 -arch x86_64 -showsplash -launcher C:Program FilesEclipseeclipse.exe -name Eclipse --launcher.library C:Program FilesEclipseplugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.1.R36x_v20100810eclipse_1309.dll -startup C:Program FilesEclipseplugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar -exitdata 1084_58 -product org.eclipse.epp.package.jee.product -vm C:Windowssystem32javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -XX:MaxPermSize=256m -jar C:Program FilesEclipseplugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar

VisualVM缩短它的位置:org.eclipse.equinox.launcher.Main

他们如何检索它?从当前的JVM中可以轻松获取所有线程的主类.

解决方法

在查看VisualVM源代码后,它会执行以下操作:

MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost("//localhost");

List<MonitoredVm> monitoredVms = new ArrayList<MonitoredVm>();
Set<Integer> vms = monitoredHost.activeVms();
for (Integer vm : vms) {
   monitoredVms.add(monitoredHost.getMonitoredVm(new VmIdentifier(vm.toString())));
}        

for (MonitoredVm monitoredVm : monitoredVms) {
   System.out.println(MonitoredVmUtil.commandLine(monitoredVm))
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读