Skip to main content

[Eclipse] Access restriction: Class is not accessible due to restriction on required library

"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

Comments

  1. This is exactly what I searched for, thanks.

    ReplyDelete
  2. thnaks for post

    ReplyDelete
  3. thanks for your post. Solved my problem!

    ReplyDelete
  4. thank you so much

    ReplyDelete
  5. thanks for the post....solved my problem!!

    ReplyDelete
  6. Thanks for this, exactly what has been annoying me for for weeks.

    ReplyDelete
  7. thanks, this saved my time.

    ReplyDelete
  8. I don't understand what these restrictions are, but thanks for the tip - made my day.

    ReplyDelete
  9. Wow...I have been searching all over the place for this answer. Thanks for posting this.

    ReplyDelete
  10. Thanks a lot. It resolved my issue

    ReplyDelete
  11. Wonderful, this one was driving me crazy !

    ReplyDelete
  12. This 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.

    ReplyDelete
  13. Good.Quick and Neat help.........
    Thanks

    ReplyDelete
  14. 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.

    ReplyDelete
  15. A BIG problem, with a SIMPLE solution.

    Thanks a lot.

    ReplyDelete
  16. 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.

    ReplyDelete
  17. Brilliant, mate! Helped me too. Thanks!

    ReplyDelete
  18. The 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.

    ReplyDelete
  19. thansk for your help

    ReplyDelete
  20. Great. You save me! :)

    ReplyDelete
  21. Saved my precious time! Thanks!

    ReplyDelete
  22. The post by Mick (June 18, 2009 4:13 PM) solved my problem. thanks!
    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.

    ReplyDelete
  23. that was really helpful ...thanks a lot

    ReplyDelete
  24. THANK YOU!!!! SOOO MUCHHHH!!! YOU SAVE MY LIFE!!!

    ReplyDelete
  25. Still useful a whole year later. Thanks!

    ReplyDelete
  26. Thanks 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 ..
    Thnx once again

    ReplyDelete
  27. 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?

    ReplyDelete
  28. Obrigado.
    esta foi uma exelente ajuda.

    ReplyDelete
  29. Thanks for this post ;-)

    ReplyDelete
  30. My problem was solved when I put the JDK at the end of the "Order and Export".

    ReplyDelete
  31. thanks you help me solve this problem

    ReplyDelete
  32. Excellent, You save me a lot of time.

    ReplyDelete
  33. "My problem was solved when I put the JDK at the end of the "Order and Export".
    Totally, its really strange why eclipse fails to load classes that are below the JRE.

    ReplyDelete
  34. Here another fix this issue:
    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".

    ReplyDelete
  35. Thanks for post, it helped, but I would like to fix this problem like Emerald214 (October 12, 2009 11:10 AM)
    "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...

    ReplyDelete
  36. Thank u very much..this was actually am looking for,,,

    ReplyDelete
  37. Although 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.

    ReplyDelete
  38. I still had the problem. Not getting solved. Could you please help me with detailed steps.
    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

    ReplyDelete
  39. Thank you very much
    god bless you

    ReplyDelete
  40. Thanks Mike for the direction.

    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.

    ReplyDelete
  41. This is exactly the kind of article I like to find when I have a problem. I's short, accurate, and does the job -- thanks.

    ReplyDelete
  42. Thanks...It worked !!!! :)

    ReplyDelete
  43. thank you very much

    ReplyDelete
  44. excellent, thanx :)

    ReplyDelete
  45. As a newbie in java, it took to much time to find this simple solution.
    Thank you very much ;)

    ReplyDelete
  46. thanks for the post, works perfect!

    ReplyDelete
  47. God 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.

    Thanks a lot

    ReplyDelete
  48. Thanks a lot. Your comments helped me.

    ReplyDelete
  49. It really helped me. Thanks.

    ReplyDelete
  50. awesome thanks.

    ReplyDelete
  51. Man...

    Thank you very much. You've saved my soul!

    xD

    ReplyDelete
  52. Proposed solution works correctly.
    Hal

    ReplyDelete
  53. Perfect. Thank you so much.

    ReplyDelete
  54. Thanks a lot!!!

    ReplyDelete
  55. thanks, very helpful

    ReplyDelete
  56. Erval Goncalves JuniorJuly 19, 2010 10:04 AM

    Thanks Kamal !!!

    ReplyDelete
  57. Thank you very much for this tip. We encountered this problem while using Eclipse Helios IDE.

    -- Ravi & Jayesh

    ReplyDelete
  58. Thanks !

    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

    ReplyDelete
  59. Thank you!!! You solved my problem!! thanks again!!

    ReplyDelete
  60. Excellent solution for my confusion

    Thanking you

    ReplyDelete
  61. awesome. I was almost getting really angry with this problem. I tried to get access to jai-core.jar. Thanks!

    ReplyDelete
  62. thanks very much!!! it's just great!

    ReplyDelete
  63. Thank you very much, this is the only resource I could find on the internet which told me how to deal with problem

    Thank you very much

    ReplyDelete
  64. Cool!
    I was stucked!

    It saved me!

    ReplyDelete
  65. thanks buddy, this is the correct solution
    ELio

    ReplyDelete
  66. Excelent !!!!

    Does anybody Know how to perform that configuration on Windows Registry ?
    ( or at some file ? )

    ReplyDelete
  67. This is exactly what I searched too !! Thank you.

    ReplyDelete
  68. Simple solution. I was looking for this for many days.

    Thanks .

    ReplyDelete
  69. Thanks for all the comments...
    For my case: I just recreated the project and everything is working...

    ReplyDelete
  70. Many thanks Kamal. You have just made my day with this....

    ReplyDelete
  71. It's great. I was looking into the read/write permissions for the lib. Thanks for the post and saved lot of time.

    ReplyDelete
  72. Thanks for the post

    ReplyDelete
  73. thanks...........

    ReplyDelete
  74. Thanks for posting. Helped me a lot!

    ReplyDelete
  75. Still relevant. Thanks.

    ReplyDelete
  76. thanks for help

    ReplyDelete
  77. Answer No. 42 helped me.

    ReplyDelete
  78. excellent, merci

    ReplyDelete
  79. THANK YOU VERY MUCH FROM SPAIN.

    ReplyDelete
  80. Great, Fantastic, Thank you so much

    ReplyDelete
  81. Great..It worked

    ReplyDelete
  82. Thanks, Its really nice answer.....

    ReplyDelete
  83. Another way of solving this issue is to delete JRE and install another JRE and change the JRE for the workspace, it will start working. :)

    Tkish

    ReplyDelete
  84. Thanks a ton.....!! U saved my time..!!

    ReplyDelete
  85. Thanks, your solution is good

    ReplyDelete
  86. thank you very much.

    ReplyDelete
  87. Thanks a lot.
    This is exactly what I was looking for.

    ReplyDelete
  88. Thank You for the help!!

    ReplyDelete
  89. Finally, two days looking for a solution. Thanks

    ReplyDelete
  90. Thank you very much for the informations;
    My code si working but it keep on give me warnings! I can't modify my access rules on jmf.jar library.

    ReplyDelete
  91. 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
    If I'll be able to modify this permissions I'll give you news :)

    ReplyDelete
  92. thanks. it helps

    ReplyDelete
  93. This is exactly what I searched for, thanks...
    u rock

    ReplyDelete
  94. THANK U VERY MUCH

    ReplyDelete
  95. Thanks for the help mate.

    ReplyDelete
  96. That was so helpful

    ReplyDelete
  97. Thanks a lot, this helped to resolve my problem

    ReplyDelete
  98. Thanks! This was driving me nuts.

    ReplyDelete
  99. I think the comment number 41 is the best solution to this problem....

    ReplyDelete
  100. Thanks a lot for this post.

    ReplyDelete
  101. This comment has been removed by a blog administrator.

    ReplyDelete
  102. This comment has been removed by a blog administrator.

    ReplyDelete
  103. This comment has been removed by a blog administrator.

    ReplyDelete
  104. This comment has been removed by a blog administrator.

    ReplyDelete
  105. Make sure you never "export" de plugin dependencies.

    So go over all required plugins and check that they are not exporting their plugin dependencies.

    ReplyDelete
  106. This comment has been removed by a blog administrator.

    ReplyDelete
  107. This comment has been removed by a blog administrator.

    ReplyDelete
  108. Thanks it helped me and
    saved my time

    ReplyDelete
  109. My JUnit tests today were giving me this error all day. I wasn't finding answers and hours have gone by.

    Reading 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!

    ReplyDelete
  110. thanks, good info.

    ReplyDelete
  111. Thanks man.........It really helped me. Keep it up.

    ReplyDelete
  112. Today is 2014... and your post still helps people! Thank you, mate!

    Cristiano

    ReplyDelete
  113. This helped me a lot! Thanks :)

    ReplyDelete
  114. You rock, this was driving me crazy

    ReplyDelete
  115. Thanks Dude.
    it really saved lot of time.

    ReplyDelete
  116. it really helped!

    ReplyDelete
  117. Thanks, It resolved my issue...

    ReplyDelete
  118. thanks for your post.this saved my time,and solved my problem.

    ReplyDelete
  119. taimoor iftikharMarch 16, 2015 11:52 PM

    thanku very very much

    ReplyDelete
  120. Sir Thank you very much....Salute to you Sir....

    ReplyDelete
  121. Awesome Thanks

    ReplyDelete
  122. cool...Thx!
    Joel Design

    ReplyDelete
  123. Thank you very much...............................

    ReplyDelete
  124. Thank you very much....

    ReplyDelete
  125. Çok teşekkür ederim
    :):)

    ReplyDelete
  126. please help me i'm only one who can't solve this probléme i have this probléme

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method JToolBar() is undefined for the type InterfaceGraphique







    ReplyDelete
  127. But how it works in fedora in eclipse

    ReplyDelete
  128. This comment has been removed by a blog administrator.

    ReplyDelete
  129. thanks good job

    ReplyDelete
  130. thank you for the post . i solve the problem

    ReplyDelete

Post a Comment

We appreciate your opinions, suggestions and criticism.

Popular posts from this blog

Web Services with Apache Axis 1.4 Tutorial: server and client sides

Java Sorting: Comparator vs Comparable Tutorial

Creative Commons License Digizol by Kamal Mettananda is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License .
URL of this page must be supplied in attribution
© 2004-2017