Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is access restricted to jre6/lib/rt.jar for OperatingSystemMxBean?

Tags:

java

I'm having a little trouble with some Java code I'm trying to compile in Eclipse. I keep getting the following warning...

Access restriction: The type OperatingSystemMXBean is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar

From this line of code...

com.sun.management.OperatingSystemMXBean bean = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();

I've found ways around this but I'm worried about the restriction warning. This code is for my open source project (CfTracker) and I don't want to work around this restriction if I'm going to be breaking some sort of license agreement. Can anyone help me understand this?

like image 324
Mister Dai Avatar asked Nov 15 '10 11:11

Mister Dai


1 Answers

Go to Window-->Preferences-->Java-->Compiler-->Error/Warnings. Select Deprecated and Restricted API. Change it to warning. Change forbidden and Discouraged Reference and change it to warning. (or as your need.)

Thanks.

like image 129
Zohaib Avatar answered Oct 17 '22 10:10

Zohaib