Restriction on required library rt.jar Error

Restriction on required library rt.jar Error

I encountered the following error in my eclipse when I import an existing project.

Access restriction: The type <class name> is not accessible due to restriction on required library C:\Program Files\Java\jdk6\jre\lib\rt.jar

After researching on the internet I found one possible reason is that, may be you are using a class that is only meant to be used by Java itself or may be you are replacing a standard class which ships with Java 6 with one in a library you have. But I can not confirm this.


The recommended Solution is to get rid of this class and use any alternative

short term Solution is remove the JRE library from your project and Add it again

for example this will work in eclipse

1. Open project properties.
2. Select Java Build Path node.
3. Select Libraries tab.
4. Remove JRE System Library.
5. Add Library JRE System Library.


And it works.

I hope both solutions helps