Access restriction on class due to restriction on required library rt.jar?
There's another solution that also works.
- Go to the Build Path settings in the project properties.
- Remove the JRE System Library
- Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.
This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first.
If you want a fundamental solution make sure you exclude the jar files with the same classes.
For me I have: javax.xml.soap.SOAPPart
in three different jars: axis-saaj-1.4.jar
, saaj-api-1.3.jar
and the rt.jar
Error: Access restriction: The type 'DataSource' is not API (restriction on required library ..\rt.jar)
Go to build path settings of your project in eclipse. Remove JRE system library. Add it again. This should resolve your error.
Access restriction on class due to restriction on required library
At a guess another library you are using also requires Apache Commons I/O, but a different version. Having a piece of code (transitively) have access to two versions of the same packages is a little tricky. You can probably arrange it so your code and the other library use the same version. It's all much easier with CLASSPATH! :)
Compiling Java with VS Code, getting restriction on required library error message
try this:
1.find .settings\org.eclipse.jdt.core.prefs
file in your project
2.change org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
to org.eclipse.jdt.core.compiler.problem.forbiddenReference = ignore
Access restriction on JavaFX classes in Eclipse Oxygen
This is discussed at length in Eclipse Bug 431067.
In addition to the workarounds in the question, the easiest is to install the e(fx)clipse plugin - https://www.eclipse.org/efxclipse/install.html.
This does the magic of configuring the necessary access restrictions within the JDK automagically.
Related Topics
Findviewbyid Returns Null in a Dialog
Android Service Needs to Run Always (Never Pause or Stop)
Java Trayicon Using Image with Transparent Background
Library to Read/Write Pbxproj/Xcodeproj Files
Creating an Array of Objects in Java
Java' Is Not Recognized as an Internal or External Command
How to Decompile a Whole Jar File
How to Read an External Properties File in Maven
Getoutputstream() Has Already Been Called for This Response
Date Object Simpledateformat Not Parsing Timestamp String Correctly in Java (Android) Environment
How to Update a Textview of an Activity from Another Class
Running Java Program from Command Line Linux
Ruby and Duck Typing: Design by Contract Impossible