Using JavaFX in JRE 8, “Access restriction” error
From the Eclipse Point of view the error is totally correct because JavaFX is coming from the extension classpath and is not available on ALL Java8 VMs (e.g. ibm!).
As outlined you can suppress those warnings by add access-rules or IMHO the best solution is to install e(fx)clipse which does this automatically for you and beside that even provides you tooling for JavaFX CSS and FXML.
You can grab an all in one package from http://efxclipse.bestsolution.at/install.html
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.
Eclipse gives warning on access restriction for jfxrt.jar classes
You can choose ignore
in the following settings:
Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
(Project) Properties -> Java Compiler -> Errors/Warnings
Use filter to find "Forbidden reference"
Forbidden reference (access rules)
: Change it to "ignore
"
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
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 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! :)
Related Topics
How to Deserialize the Object, If It Was Moved to Another Package or Renamed
Nextdouble() Throws an Inputmismatchexception When I Enter a Double
Checking for a Null Int Value from a Java Resultset
Port of Random Generator from C to Java
How to Change My Windows Desktop Wallpaper Programmatically in Java/Groovy
Java Xml Parser for Huge Files
Java Variable Number of Arguments for a Method
Why Isn't This Code Causing a Concurrentmodificationexception
Play a Youtube Video Using Javafx
Comparing Time Is Incorrect When Picking 12:00
What Is the Purpose of the Java Constant Pool