Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

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

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 FilesJavajre6lib
t.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...