I have configured my Eclipse
to use JRE 8
. I confirmed it in buildPath
.
The compiler
is specified as 1.8
.
I am trying to get the SystemCpuLoad
. Here is what I have.
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
operatingSystemBean.getSystemCpuLoad();
Eclipse complains saying "no getSystemCpuLoad()" method.
I thought it could be an eclipse
issue and try using maven
.
still build fails with the following error.
java:[221,60] cannot find symbol
[ERROR] symbol: method getSystemCpuLoad()
[ERROR] location: variable operatingSystemBean of type java.lang.management.OperatingSystemMXBean
I am unable to figure what is going wrong?
EDIT:
In the documentation it says
Platform-specific management interface for the operating system on which the Java virtual machine is running.
which means some methods are available in one OS than others. but how can I handle it during compile time to run in linux or mac?
I am currently using mac.