Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access restriction on class due to restriction on required library

Tags:

I get this error message in Eclipse:

Access restriction: The type DirectoryWalker is not accessible
due to restriction on required library 
/Library/Java/Extensions/commons-io-1.4.jar

what does this mean? There's this other SO question on the same topic but it doesn't seem to apply in this case. I'm not creating a new java class, I'm trying to use one.

like image 733
Jason S Avatar asked Jul 07 '09 01:07

Jason S


People also ask

How to resolve access restriction in Eclipse?

Assuming you are using Eclipse + m2e maven plugin, if you get this access restriction error, right click on the project/module in which you have the error --> Properties --> Build Path --> Library --> Replace JDK/JRE to the one that is used in eclipse workspace. I followed the above steps and the issue is resolved.

What is RT jar file in Java?

rt. jar contains all of the compiled class files for the base Java Runtime environment, as well as the bootstrap classes, which are the run time classes that comprise the Java platform core API.


2 Answers

go to java build path and under Library tab, remove JRE System Library. Then again Add Library --> JRE System Library

Worked for me

like image 126
Maheen Avatar answered Oct 20 '22 07:10

Maheen


This is my least-favorite error, I've run into it a few times, and the "restriction on required library" is just dull enough to leave you scratching your head. However, it's easy to fix.

The quickest way (I'm using Helios) is to go to Window->Preferences->Java->Compiler->Errors/Warnings, find and open the "Deprecated and Restricted API" bullet, and set Forbidden and Discouraged Reference to something other than Error.

"Warning" is usually best, as something out there in Java land is triggering this and you probably want a footnote on it. @SuppressWarnings and its cousins, 98% of the time, have the same effect on a programmer's personal and social logic as, say, an ether binge might. But that's just my humble analysis.

Best of luck!

like image 31
Michael Eric Oberlin Avatar answered Oct 20 '22 08:10

Michael Eric Oberlin