-1
我需要使用java獲得計算機的總RAM大小。我已經試過這樣:Java獲得可用內存(eclipse)
package test;
import java.lang.management.ManagementFactory;
public class test1 {
public static void main(String[] args) {
com.sun.management.OperatingSystemMXBean mxbean =
(com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
float a = mxbean.getTotalPhysicalMemorySize();
System.out.println(a + " bytes");
}
}
而且我有一個錯誤:
Access restriction: The type OperatingSystemMXBean is not accessible due to restriction on required library /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/rt.jar
不錯! thx老兄! :D現在都在工作 – starkmax