Java Code Examples for java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME

The following are Jave code examples for showing how to use RUNTIME_MXBEAN_NAME of the java.lang.management.ManagementFactory class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jdk8u-jdk   File: MXBeanInteropTest1.java   View Source Code Vote up 4 votes
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
Example 2
Project: openjdk-jdk10   File: MXBeanInteropTest1.java   View Source Code Vote up 4 votes
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}