Here you can find the source of invokeMXMethod(String methodName)
public static Object invokeMXMethod(String methodName) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
//package com.java2s; //License from project: Apache License import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static Object invokeMXMethod(String methodName) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); Method m = operatingSystemMXBean.getClass().getDeclaredMethod(methodName); m.setAccessible(true);// w w w . jav a 2 s . c om return m.invoke(operatingSystemMXBean); } }