您好我无法在我的
java程序中使用getProcesscpuTime()或getProcesscpuLoad()或getSystemcpuLoad().我用过如下.
ManagementFactory. getOperatingSystemMXBean().getProcesscpuTime();
也是这样的
( (OperatingSystemMXBean) getOperatingSystemMXBean() ).getProcesscpuTime()
但是找不到像方法getProcesscpuTime()那样的显示错误.我包括以下头文件.这还不够,或者我需要再使用了.?
import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean;
任何人都可以建议我如何使用这些方法.我正在使用jdk1.6.我的代码如下
import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.lang.reflect.Method; import java.lang.reflect.Modifier; public class printUsage { public static void main(String[] args) { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); System.out.println("getcpuProcessTime()" + " = " + operatingSystemMXBean.getProcesscpuTime()); System.out.println("getcpuProcessTime()" + " = " + operatingSystemMXBean.getSystemcpuLoad()); System.out.println("getcpuProcessTime()" + " = " + operatingSystemMXBean.getProcesscpuLoad()); } }