有什么方法可以显示正在运行的JVM中使用的标志? [英] Is there any way to show the flags being used in a running JVM?

查看:62
本文介绍了有什么方法可以显示正在运行的JVM中使用的标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我们已为应用程序显式设置了许多JVM标志,但很难知道是否: 1.默认情况下,布尔标志已打开(在次要JDK/JRE更新之间更改了默认设置) 2.一个标志否定另一个 3.给定的任意标志的默认值在您的特定系统上是什么(由Java人体工程学设置)

Although we've explicitly set a number of JVM flags for our applications, it's very difficult to know if: 1. Boolean flags are already on by default (defaults changed between minor JDK/JRE updates) 2. One flag negates the other 3. What the default value of a given arbitrary flag is on your specific systems (Set by Java ergonomics)

总结一下: 是否有类似于

To sum up: Is there a command line tool similar to

java -XX:+PrintFlagsFinal

,在哪里可以检查已经运行的JVM的所有标志值?

, where I can check the all flag values for an already running JVM?

推荐答案

对于HotSpot,您可以使用(来自ehcache)

For HotSpot you can use (From ehcache)

private static String getHotSpotVmOptionValue(String name) {
    try {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName beanName = ObjectName.getInstance("com.sun.management:type=HotSpotDiagnostic");
        Object vmOption = server.invoke(beanName, "getVMOption", new Object[] {name}, new String[] {"java.lang.String"});
        return (String)((CompositeData)vmOption).get("value");
    } catch (Throwable t) {
        return null;
    }
}

这篇关于有什么方法可以显示正在运行的JVM中使用的标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆