如何为 VisualVM“<未知应用程序>”命名?未知应用程序>
JDK 1.6 捆绑了一个名为 VisualVM 的便捷工具,可让您检查正在运行的 Java 进程并与之交互。其中一项功能是它会自动检测本地计算机上正在运行的 JVM。大多数被列为“(pid xxxx)”,但有些有名称和图标,例如 VisualVM 本身和其他类似 NetBeans(请参见 这篇 dzone 文章)。
如何将应用程序名称和图标注入 JVM,以便它正确显示在 VisualVM 的应用程序列表中?我的应用程序需要运行 JRE 1.6 还是我也可以在 1.5 下执行此操作?
JDK 1.6 comes bundled with a handy tool called VisualVM that lets you inspect and interact with running Java processes. One feature is that it auto-detects running JVMs on the local machine. Most are listed as " (pid xxxx)" but some have a name and an icon, like VisualVM itself and others like NetBeans (see the screenshot in this dzone article for example).
How do I inject my application name and icon into the JVM so it shows up properly in VisualVM's application list? Does my app need to be running JRE 1.6 or can I do this under 1.5 too?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过 NetBeans 论坛帖子 答案解决了我自己的问题的一半。添加
-Dvisualvm.display.name=FooBar
的 JVM 命令行参数使 VisualVM 将应用程序显示为“FooBar”。但我仍然不知道如何影响图标。更新:唉,我想我找到了图标的答案。这些图标通过 MainClassApplicationTypeFactory,从静态方法 ApplicationTypeFactory.getApplicationTypeFor(Application) 调用。除了创建一个可以注册新类型工厂的 VisualVM 插件之外,我看不出有任何方法可以将新图标注入到 VisualVM 中——例如,Glassfish 插件通过 GlassFishApplicationTypeFactory.initialize() 来完成此操作。
I solved half of my own question via a NetBeans forum post answer. Adding a JVM command line arg of
-Dvisualvm.display.name=FooBar
makes VisualVM show the app as "FooBar". But I still can't figure out how to affect the icon.UPDATE: Alas, I think I found my answer for the icon. The icons are hard-coded into VisualVM via MainClassApplicationTypeFactory in the VisualVM source, invoked from the static method ApplicationTypeFactory.getApplicationTypeFor(Application). I can't see any way to inject a new icon into VisualVM except by making a VisualVM plugin which could register a new type factory -- the Glassfish plugin does this via GlassFishApplicationTypeFactory.initialize() for example.