"Access restriction: Class is not accessible due to restriction on required library"; error message may be shown while developing Java projects in Eclipse IDE. Error message is self-explanatory, some classes can not be loaded into the project since restriction rules are being imposed on those classes.
Locate the "Forbidden reference (access rules)" option under "Deprecated and restricted API" section in the dialog box. This option decides how to handle access rules defined inside Eclipse. By default it is set to "Error" which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.
"Warning" or "Ignore" options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined access rules. To completely resolve this issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or access rules).
How to solve
This error message can be removed by changing a setting inside Eclipse IDE. Open up the dialog box shown below, using any of the following paths.- Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
- (Project) Properties -> Java Compiler -> Errors/Warnings
Locate the "Forbidden reference (access rules)" option under "Deprecated and restricted API" section in the dialog box. This option decides how to handle access rules defined inside Eclipse. By default it is set to "Error" which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages."Warning" or "Ignore" options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined access rules. To completely resolve this issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or access rules).
Labels: Eclipse, Java, Software, Tech, Tools
Kamal Mettananada is a software engineer, Java explorer & author of Digizol, blog with computer related articles, tutorials, tips and many other information.
127 Comments for "[Eclipse] Access restriction: Class is not accessible due to restriction on required library"
Thanks
Thanks a lot.
My problem is "Access restriction to all class in /usr/java/zenith_jdk1.6.0_04/jre/lib/rt.jar".
The solution for me was to change the (Project) Properties -> Order/Export (I think this is class loader order), I just moved the "JRE System Library [zenith_jdk1.6.0_04]" above others.
Thnx once again
esta foi uma exelente ajuda.
Totally, its really strange why eclipse fails to load classes that are below the JRE.
I get the "Access restriction: The type xxxxx is not accessible due to restriction on required project.." compilation error ¶
* If you just created a new service interface, then you probably forgot to add it in the "Exported Packages" of the .services project.
* If you encounter rt.jar Restrictions (on com.sun... classes for example) - these seem to be built-in Restrictions of Eclipse 3.3/OSGi and indicate you are doing something deprecated in OSGi. Try to do it "the right way".
"I'm using Eclipse with JMF's just been installed. I don't like to hide this error. I'd like to resolve it completely. Anyone helps me? ".
What do I need to do then? I'm using JMF too...
Access restriction: The type Vector3d is not accessible due to restriction on required library C:\Program Files (x86)\Java\jre1.5.0_06\lib\ext\vecmath.jar
god bless you
This is how I did in Eclipse 3.5:
Right Click on Project and select Properties -> Java Build Path -> Libraries (Tab)
expand the rt.jar and see where you have forbidden access (**/*) in my case.
Now edit "access rules" -> Add -> Resolution = "Accessible" and Rule Pattern = **/*
Click OK and you are done.
Thank you very much ;)
Thanks a lot
Thank you very much. You've saved my soul!
xD
Hal
-- Ravi & Jayesh
Had the same problem (with maven) :
Access restriction: The type XXX is not accessible due to restriction on required library C:\bin\dvlp\java\jdk1.6.0_07\jre\lib\rt.jar
Thanking you
Thank you very much
I was stucked!
It saved me!
ELio
Does anybody Know how to perform that configuration on Windows Registry ?
( or at some file ? )
Thanks .
For my case: I just recreated the project and everything is working...
Tkish
This is exactly what I was looking for.
My code si working but it keep on give me warnings! I can't modify my access rules on jmf.jar library.
If I'll be able to modify this permissions I'll give you news :)
u rock