"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.
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).
Related Articles
This is exactly what I searched for, thanks.
ReplyDeletethnaks for post
ReplyDeleteGreat!
ReplyDeletethanks for your post. Solved my problem!
ReplyDeletesolved my problem. thanks!
ReplyDeletethanks for the post....solved my problem!!
ReplyDeleteThanks for this, exactly what has been annoying me for for weeks.
ReplyDeletethanks, this saved my time.
ReplyDeletethanks dude!!
ReplyDeleteI don't understand what these restrictions are, but thanks for the tip - made my day.
ReplyDeleteWow...I have been searching all over the place for this answer. Thanks for posting this.
ReplyDeleteThanks a lot. It resolved my issue
ReplyDeleteWonderful, this one was driving me crazy !
ReplyDeleteThis post does not appear to provide a satisfactory solution to the problem, but merely explains how to make the warning go away. If you see the error "Access restriction: The method (name) from the type (class) is not accessible due to restriction on required project (project)" can be solved by 1) Right click on the project with the problem and select "properties"; 2) Select "Java Build Path"; 3) Expand "Plug-in Dependencies" and expand the project causing the problem; 4) Expand "Access rules" and modify them to ensure the referenced class is accessible.
ReplyDeleteGood.Quick and Neat help.........
ReplyDeleteThanks
The post by Anonymous on March 27, 2009 1:59AM does not solve the problem either. By modifying the Access Rules you are simply hiding the problem. The Access Rules are there for a reason and you need to fix the problem. If you don't, you are probably in violation of the Java license.
ReplyDeleteA BIG problem, with a SIMPLE solution.
ReplyDeleteThanks a lot.
I encountered this when creating a maven apache cxf prototype. The problem was not fixable by changing access rules for the library because these were not modifiable. The solution for me was to use a newer JDK or change the Order/Export (I think this is class loader order) so the Maven-supplied jaxb-api2.1.jar was used. The workspace Java 1.5 system library was not correctly exporting the javax.jws.* package. My approach was just to change the system library to a 1.6 one.
ReplyDeleteBrilliant, mate! Helped me too. Thanks!
ReplyDeleteThanks dude.
ReplyDeleteThe Anonymous of March 27, 2009 1:59 AM was right. The other way to do the same things is to use plugin editor and add there on Runtime page the project/package you want to get from the class with error. This will allow the package to export. But this solution makes sense only for those who works with several projects of their own (like in case of plug-ins development). In simple cases when the error doesn't say anything to you the suggested by Kamal way is possibly one you are looking for. And then don't mess with the restriction editing.
ReplyDeletethansk for your help
ReplyDeleteGreat. You save me! :)
ReplyDeleteSaved my precious time! Thanks!
ReplyDeleteThe post by Mick (June 18, 2009 4:13 PM) solved my problem. thanks!
ReplyDeleteMy 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.
that was really helpful ...thanks a lot
ReplyDeletethanks
ReplyDeleteTHANK YOU!!!! SOOO MUCHHHH!!! YOU SAVE MY LIFE!!!
ReplyDeletethanks a lot
ReplyDeletethanks!!!
ReplyDeleteStill useful a whole year later. Thanks!
ReplyDeleteThanks Dude .. I was bugged with the problem and wasted a lot of time on it .. went through a number of posts .. but finally this is what I was looking for ..
ReplyDeleteThnx once again
Thanks for the post dude
ReplyDeleteI'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?
ReplyDeleteObrigado.
ReplyDeleteesta foi uma exelente ajuda.
Thanks for this post ;-)
ReplyDeleteMy problem was solved when I put the JDK at the end of the "Order and Export".
ReplyDeletethanks you help me solve this problem
ReplyDeleteExcellent, You save me a lot of time.
ReplyDelete"My problem was solved when I put the JDK at the end of the "Order and Export".
ReplyDeleteTotally, its really strange why eclipse fails to load classes that are below the JRE.
Here another fix this issue:
ReplyDeleteI 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".
THANK YOU! =)
ReplyDeletethanks. superb
ReplyDeleteThanks for post, it helped, but I would like to fix this problem like Emerald214 (October 12, 2009 11:10 AM)
ReplyDelete"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...
Thank u very much..this was actually am looking for,,,
ReplyDeleteAlthough this doesn't tell me why I got this error, it does tell me how to successfully ignore it until I have time to figure it out, which is great. Thanks for saving me a lot of time.
ReplyDeleteI still had the problem. Not getting solved. Could you please help me with detailed steps.
ReplyDeleteAccess 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
Thank you very much
ReplyDeletegod bless you
Thanks Mike for the direction.
ReplyDeleteThis 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.
thanks
ReplyDeleteThis is exactly the kind of article I like to find when I have a problem. I's short, accurate, and does the job -- thanks.
ReplyDeleteThanks...It worked !!!! :)
ReplyDeletethank you very much
ReplyDeleteexcellent, thanx :)
ReplyDeleteAs a newbie in java, it took to much time to find this simple solution.
ReplyDeleteThank you very much ;)
thanks for the post, works perfect!
ReplyDeleteGod bless you, I was desperatly. My message said "Access restriction: TYPE is not accessible due to restriction on required library" instead of class but worked for me too.
ReplyDeleteThanks a lot
Thanks a lot. Your comments helped me.
ReplyDeleteIt really helped me. Thanks.
ReplyDeleteawesome thanks.
ReplyDeleteMan...
ReplyDeleteThank you very much. You've saved my soul!
xD
Thank you !
ReplyDeleteProposed solution works correctly.
ReplyDeleteHal
Perfect. Thank you so much.
ReplyDeleteThanks a lot!!!
ReplyDeleteThanks!
ReplyDeleteThanks
ReplyDeletethanks, very helpful
ReplyDeleteThanks Kamal !!!
ReplyDeleteThank you very much for this tip. We encountered this problem while using Eclipse Helios IDE.
ReplyDelete-- Ravi & Jayesh
magnificent!
ReplyDeleteThanks
ReplyDeleteThanks !
ReplyDeleteHad 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
Thank you!!! You solved my problem!! thanks again!!
ReplyDeleteExcellent solution for my confusion
ReplyDeleteThanking you
awesome. I was almost getting really angry with this problem. I tried to get access to jai-core.jar. Thanks!
ReplyDeletethanks very much!!! it's just great!
ReplyDeleteThank you very much, this is the only resource I could find on the internet which told me how to deal with problem
ReplyDeleteThank you very much
Cool!
ReplyDeleteI was stucked!
It saved me!
thank you.....
ReplyDeletethanks buddy, this is the correct solution
ReplyDeleteELio
thanks a Lot!
ReplyDeleteExcelent !!!!
ReplyDeleteDoes anybody Know how to perform that configuration on Windows Registry ?
( or at some file ? )
This is exactly what I searched too !! Thank you.
ReplyDeleteSimple solution. I was looking for this for many days.
ReplyDeleteThanks .
Thanks for all the comments...
ReplyDeleteFor my case: I just recreated the project and everything is working...
Thanks!
ReplyDeleteMany thanks Kamal. You have just made my day with this....
ReplyDeleteIt's great. I was looking into the read/write permissions for the lib. Thanks for the post and saved lot of time.
ReplyDeleteThanks for the post
ReplyDeletethanks :-)
ReplyDeletethanks
ReplyDeletethanks...........
ReplyDeleteThanks for posting. Helped me a lot!
ReplyDeleteStill relevant. Thanks.
ReplyDeletethanks for help
ReplyDeleteAnswer No. 42 helped me.
ReplyDeleteexcellent, merci
ReplyDeleteTHANK YOU VERY MUCH FROM SPAIN.
ReplyDeleteGreat, Fantastic, Thank you so much
ReplyDeleteGreat..It worked
ReplyDeleteThanks, Its really nice answer.....
ReplyDeleteAnother way of solving this issue is to delete JRE and install another JRE and change the JRE for the workspace, it will start working. :)
ReplyDeleteTkish
Thanks a ton.....!! U saved my time..!!
ReplyDeleteThanks, your solution is good
ReplyDeletethank you very much.
ReplyDeleteThanks a lot.
ReplyDeleteThis is exactly what I was looking for.
Thank You for the help!!
ReplyDeleteFinally, two days looking for a solution. Thanks
ReplyDeleteThank you very much for the informations;
ReplyDeleteMy code si working but it keep on give me warnings! I can't modify my access rules on jmf.jar library.
Thank you for this article; now I can run my code even if I still have some wornings because I can't edit access rules on jmf.rar
ReplyDeleteIf I'll be able to modify this permissions I'll give you news :)
thanks. it helps
ReplyDeleteThis is exactly what I searched for, thanks...
ReplyDeleteu rock
thx
ReplyDeleteGod bless you for this post!
ReplyDeleteTHANK U VERY MUCH
ReplyDeleteThanks for the help mate.
ReplyDeleteThat was so helpful
ReplyDeleteThanks a lot, this helped to resolve my problem
ReplyDeleteThis was helpful !
ReplyDeleteThanks. it helps
ReplyDeletewrite once, help many
ReplyDeleteThanks! This was driving me nuts.
ReplyDeleteThanks you, it helps me
ReplyDeleteThanks you, it helps me
ReplyDeleteI think the comment number 41 is the best solution to this problem....
ReplyDeleteThanks a lot for this post.
ReplyDeleteThank U Boss
ReplyDeleteMake sure you never "export" de plugin dependencies.
ReplyDeleteSo go over all required plugins and check that they are not exporting their plugin dependencies.
Thanks it helped me and
ReplyDeletesaved my time
My JUnit tests today were giving me this error all day. I wasn't finding answers and hours have gone by.
ReplyDeleteReading your solution left me questioning if this was actually a non-issue. Upon following your guide I was able to compile the code and tests were acting as expected. I will continue to look into this warning and thank you for your post!
thanks, good info.
ReplyDeleteThanks man.........It really helped me. Keep it up.
ReplyDeleteToday is 2014... and your post still helps people! Thank you, mate!
ReplyDeleteCristiano
Thanks, this solve my problem!!
ReplyDeleteThis helped me a lot! Thanks :)
ReplyDeleteYou rock, this was driving me crazy
ReplyDeleteExactly done it !Help Full
ReplyDeleteThanks Dude.
ReplyDeleteit really saved lot of time.
it really helped!
ReplyDeleteThanks, It resolved my issue...
ReplyDeletethanks for your post.this saved my time,and solved my problem.
ReplyDeletethanku very very much
ReplyDeleteSir Thank you very much....Salute to you Sir....
ReplyDeleteThank You!!!
ReplyDeleteAwesome Thanks
ReplyDeletecool...Thx!
ReplyDeleteJoel Design
Thank you very much...............................
ReplyDeleteThank you very much....
ReplyDeleteÇok teşekkür ederim
ReplyDelete:):)
please help me i'm only one who can't solve this probléme i have this probléme
ReplyDeleteException in thread "main" java.lang.Error: Unresolved compilation problem:
The method JToolBar() is undefined for the type InterfaceGraphique
But how it works in fedora in eclipse
ReplyDeletethanks good job
ReplyDeletethank you for the post . i solve the problem
ReplyDelete(y) Glad to hear that.
Delete