Java News Tips Software
Java News Tips Software | Contact | Facebook | Twitter RSS

[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).

Labels: , , , ,


  1. This is exactly what I searched for, thanks.
  2. Anonymous Anonymous on October 08, 2008 8:06 PM  
    thnaks for post
  3. Anonymous Anonymous on October 22, 2008 12:46 AM  
  4. thanks for your post. Solved my problem!
  5. solved my problem. thanks!
  6. thank you so much
  7. thanks for the post....solved my problem!!
  8. Thanks for this, exactly what has been annoying me for for weeks.
  9. Anonymous Anonymous on January 21, 2009 2:37 PM  
    thanks, this saved my time.
  10. Anonymous Anonymous on January 29, 2009 5:34 PM  
    thanks dude!!
  11. Anonymous Anonymous on February 11, 2009 7:55 PM  
    I don't understand what these restrictions are, but thanks for the tip - made my day.
  12. Anonymous Anonymous on February 20, 2009 9:59 AM  
    Wow...I have been searching all over the place for this answer. Thanks for posting this.
  13. Anonymous Anonymous on March 09, 2009 8:17 PM  
    Thanks a lot. It resolved my issue
  14. Anonymous Anonymous on March 23, 2009 1:33 PM  
    Wonderful, this one was driving me crazy !
  15. Anonymous Anonymous on March 27, 2009 1:59 AM  
    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.
  16. Anonymous Anonymous on May 07, 2009 12:02 AM  
    Good.Quick and Neat help.........
  17. Anonymous Anonymous on May 29, 2009 10:25 AM  
    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.
  18. Anonymous Anonymous on June 03, 2009 4:00 AM  
    A BIG problem, with a SIMPLE solution.

    Thanks a lot.
  19. 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.
  20. Anonymous Anonymous on June 19, 2009 12:51 PM  
    Brilliant, mate! Helped me too. Thanks!
  21. Anonymous Anonymous on June 27, 2009 9:01 PM  
    Thanks dude.
  22. Anonymous Anonymous on July 13, 2009 8:00 PM  
    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.
  23. Anonymous Anonymous on July 15, 2009 2:41 PM  
    thansk for your help
  24. Anonymous Anonymous on July 22, 2009 3:00 AM  
    Great. You save me! :)
  25. Anonymous Anonymous on August 05, 2009 5:22 PM  
    Saved my precious time! Thanks!
  26. Anonymous Anonymous on August 14, 2009 4:40 PM  
    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.
  27. Anonymous Anonymous on August 15, 2009 8:15 PM  
    that was really helpful ...thanks a lot
  28. thanks
  29. Anonymous Anonymous on August 27, 2009 5:28 AM  
  30. thanks a lot
  31. thanks!!!
  32. Still useful a whole year later. Thanks!
  33. 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
  34. Thanks for the post dude
  35. Anonymous Emerald214 on 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?
  36. Anonymous Anonymous on October 30, 2009 5:13 PM  
    esta foi uma exelente ajuda.
  37. Thanks for this post ;-)
  38. Anonymous Anonymous on November 06, 2009 7:09 PM  
    My problem was solved when I put the JDK at the end of the "Order and Export".
  39. Anonymous Anonymous on November 23, 2009 9:31 AM  
    thanks you help me solve this problem
  40. Anonymous Anonymous on December 08, 2009 3:54 PM  
    Excellent, You save me a lot of time.
  41. "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.
  42. Anonymous Anonymous on December 22, 2009 9:57 AM  
    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".
  43. Anonymous Anonymous on January 06, 2010 3:27 AM  
    THANK YOU! =)
  44. Anonymous Anonymous on January 06, 2010 6:18 PM  
    thanks. superb
  45. Anonymous Anonymous on January 29, 2010 10:56 PM  
    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...
  46. Thank u very much..this was actually am looking for,,,
  47. 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.
  48. Anonymous Anonymous on February 09, 2010 4:03 AM  
    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
  49. Thank you very much
    god bless you
  50. 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.
  51. Anonymous Anonymous on March 06, 2010 9:20 PM  
  52. Anonymous Anonymous on March 07, 2010 2:20 AM  
    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.
  53. Anonymous Anonymous on March 10, 2010 12:38 PM  
    Thanks...It worked !!!! :)
  54. Anonymous Anonymous on March 10, 2010 9:14 PM  
    thank you very much
  55. Anonymous Anonymous on March 17, 2010 11:49 AM  
    excellent, thanx :)
  56. Anonymous Anonymous on March 19, 2010 11:10 PM  
    As a newbie in java, it took to much time to find this simple solution.
    Thank you very much ;)
  57. Anonymous Anonymous on April 05, 2010 9:50 PM  
    thanks for the post, works perfect!
  58. Anonymous Anonymous on April 25, 2010 6:25 PM  
    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
  59. Anonymous Anonymous on May 07, 2010 2:05 PM  
    Thanks a lot. Your comments helped me.
  60. Anonymous Anonymous on May 13, 2010 9:55 AM  
    It really helped me. Thanks.
  61. Anonymous Anonymous on May 14, 2010 3:16 AM  
    awesome thanks.
  62. Anonymous Anonymous on June 02, 2010 6:19 AM  

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

  63. Anonymous Anonymous on June 05, 2010 12:00 PM  
    Thank you !
  64. Anonymous Anonymous on June 07, 2010 2:57 PM  
    Proposed solution works correctly.
  65. Anonymous Anonymous on June 17, 2010 8:30 AM  
    Perfect. Thank you so much.
  66. Anonymous Anonymous on June 18, 2010 3:41 PM  
    Thanks a lot!!!
  67. Anonymous Anonymous on June 22, 2010 11:13 AM  
  68. Anonymous Anonymous on June 27, 2010 7:59 PM  
  69. Anonymous Anonymous on July 07, 2010 8:17 PM  
    thanks, very helpful
  70. Anonymous Erval Goncalves Junior on July 19, 2010 10:04 AM  
    Thanks Kamal !!!
  71. Anonymous Anonymous on July 21, 2010 4:50 PM  
    Thank you very much for this tip. We encountered this problem while using Eclipse Helios IDE.

    -- Ravi & Jayesh
  72. Anonymous Anonymous on July 22, 2010 2:43 AM  
  73. Anonymous Anonymous on July 29, 2010 4:35 PM  
  74. Anonymous Anonymous on August 10, 2010 7:06 PM  
    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
  75. Anonymous Anonymous on August 14, 2010 1:53 AM  
    Thank you!!! You solved my problem!! thanks again!!
  76. Anonymous Anonymous on August 28, 2010 1:04 AM  
    Excellent solution for my confusion

    Thanking you
  77. awesome. I was almost getting really angry with this problem. I tried to get access to jai-core.jar. Thanks!
  78. thanks very much!!! it's just great!
  79. 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
  80. Anonymous Anonymous on October 16, 2010 8:25 PM  
    I was stucked!

    It saved me!
  81. thank you.....
  82. thanks buddy, this is the correct solution
  83. Anonymous Anonymous on November 12, 2010 4:47 PM  
    thanks a Lot!
  84. Anonymous Anonymous on November 23, 2010 9:55 PM  
    Excelent !!!!

    Does anybody Know how to perform that configuration on Windows Registry ?
    ( or at some file ? )
  85. Anonymous Anonymous on December 03, 2010 6:48 PM  
    This is exactly what I searched too !! Thank you.
  86. Anonymous Anonymous on December 09, 2010 2:45 PM  
    Simple solution. I was looking for this for many days.

    Thanks .
  87. Thanks for all the comments...
    For my case: I just recreated the project and everything is working...
  88. Thanks!
  89. Anonymous Anonymous on January 07, 2011 10:34 PM  
    Many thanks Kamal. You have just made my day with this....
  90. Anonymous Anonymous on January 11, 2011 12:28 AM  
    It's great. I was looking into the read/write permissions for the lib. Thanks for the post and saved lot of time.
  91. Anonymous Anonymous on January 12, 2011 4:03 PM  
    Thanks for the post
  92. Anonymous Anonymous on January 22, 2011 2:46 AM  
    thanks :-)
  93. Anonymous Anonymous on February 15, 2011 4:59 AM  
  94. Anonymous Anonymous on March 03, 2011 9:51 PM  
  95. Anonymous Anonymous on March 05, 2011 10:24 AM  
    Thanks for posting. Helped me a lot!
  96. Anonymous Anonymous on March 26, 2011 3:14 AM  
    Still relevant. Thanks.
  97. Anonymous Anonymous on March 30, 2011 3:21 PM  
    thanks for help
  98. Anonymous Mrudula on April 21, 2011 6:18 PM  
    Answer No. 42 helped me.
  99. Anonymous Anonymous on May 17, 2011 9:49 PM  
    excellent, merci
  100. Anonymous Anonymous on May 19, 2011 11:57 PM  
  101. Great, Fantastic, Thank you so much
  102. Anonymous Anonymous on June 02, 2011 9:28 PM  
    Great..It worked
  103. Anonymous Anonymous on June 14, 2011 5:37 PM  
    Thanks, Its really nice answer.....
  104. Anonymous Anonymous on June 15, 2011 7:25 PM  
    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. :)

  105. Anonymous Anonymous on June 24, 2011 12:19 PM  
    Thanks a ton.....!! U saved my time..!!
  106. Anonymous Anonymous on June 28, 2011 8:00 PM  
    Thanks, your solution is good
  107. Anonymous Anonymous on July 18, 2011 11:24 AM  
    thank you very much.
  108. Thanks a lot.
    This is exactly what I was looking for.
  109. thanks!
  110. Thank You for the help!!
  111. Anonymous J.A.E Spain on November 26, 2011 10:10 PM  
    Finally, two days looking for a solution. Thanks
  112. 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.
  113. 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 :)
  114. Anonymous Anonymous on January 09, 2012 12:08 PM  
    thanks. it helps
  115. Anonymous Anonymous on January 26, 2012 11:33 PM  
    This is exactly what I searched for, thanks...
    u rock
  116. thx
  117. God bless you for this post!
  118. Anonymous Anonymous on March 25, 2012 5:57 PM  
  119. Anonymous Anonymous on July 06, 2012 9:41 AM  
    Thanks for the help mate.
  120. Anonymous Anonymous on August 31, 2012 6:15 PM  
    That was so helpful
  121. Thanks a lot, this helped to resolve my problem
  122. This was helpful !
  123. Thanks. it helps
  124. write once, help many
  125. Anonymous Anonymous on October 24, 2012 1:59 AM  
    Thanks! This was driving me nuts.
  126. Thanks you, it helps me
  127. Thanks you, it helps me
  128. I think the comment number 41 is the best solution to this problem....
  129. Anonymous Uday Mandava on July 10, 2013 7:59 PM  
    Thanks a lot for this post.
  130. Anonymous Anonymous on November 25, 2013 7:58 PM  
    This comment has been removed by a blog administrator.
  131. Anonymous Anonymous on December 09, 2013 5:11 PM  
    This comment has been removed by a blog administrator.
  132. Anonymous Anonymous on December 18, 2013 5:22 AM  
    This comment has been removed by a blog administrator.
  133. Anonymous Anonymous on January 04, 2014 1:05 PM  
    Thank U Boss
  134. Anonymous Anonymous on January 05, 2014 12:44 AM  
    This comment has been removed by a blog administrator.
  135. Make sure you never "export" de plugin dependencies.

    So go over all required plugins and check that they are not exporting their plugin dependencies.
  136. Anonymous Anonymous on March 30, 2014 12:34 AM  
    This comment has been removed by a blog administrator.
  137. This comment has been removed by a blog administrator.
  138. Thanks it helped me and
    saved my time
  139. 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!
  140. Anonymous Anonymous on July 15, 2014 3:27 AM  
    thanks, good info.
  141. Thanks man.........It really helped me. Keep it up.
  142. Today is 2014... and your post still helps people! Thank you, mate!

  143. Thanks, this solve my problem!!
  144. Anonymous Anonymous on November 18, 2014 5:00 AM  
    This helped me a lot! Thanks :)
  145. Anonymous Anonymous on November 22, 2014 8:27 AM  
    You rock, this was driving me crazy
  146. Exactly done it !Help Full
  147. Anonymous Anonymous on January 11, 2015 7:19 AM  
    Thanks Dude.
    it really saved lot of time.
  148. Anonymous Anonymous on January 11, 2015 7:21 AM  
    it really helped!
  149. Anonymous Anonymous on March 10, 2015 7:08 AM  
    Thanks, It resolved my issue...
  150. Anonymous Anonymous on March 14, 2015 6:04 PM  
    thanks for your post.this saved my time,and solved my problem.
  151. Anonymous taimoor iftikhar on March 16, 2015 11:52 PM  
    thanku very very much
  152. Sir Thank you very much....Salute to you Sir....
  153. Thank You!!!
  154. Anonymous Anonymous on August 10, 2015 9:39 PM  
    Awesome Thanks
  155. Anonymous Anonymous on August 20, 2015 7:23 PM  
    Joel Design
  156. Anonymous Anonymous on November 10, 2015 4:53 PM  
    Thank you very much...............................
  157. Anonymous Anonymous on November 10, 2015 4:54 PM  
    Thank you very much....
  158. Anonymous Anonymous on January 07, 2016 1:10 AM  
    Çok teşekkür ederim
  159. 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

  160. But how it works in fedora in eclipse
  161. This comment has been removed by a blog administrator.
  162. Anonymous Anonymous on May 16, 2017 5:11 AM  
    thanks good job
Page Views :
Email :
Select Month:
Free counter and web stats