I'm using Eclipse Oxygen 4.7.0 in Ubuntu 17.04 with Oracle JDK 8u144.
Any code that refers to JavaFX classes in packages javafx.*
, e.g. javafx.application.Application
is (incorrectly) reported as an error
Access restriction: The type 'ScrollPane' is not API (restriction on required library '/opt/jdk1.8.0_144/jre/lib/ext/jfxrt.jar')
This appears to be related to the "Java System Library" JavaSE-1.8. The jfxrt.jar
has "Access rules" you can view in Properties -> Java Build Path, these only permit javax/, java/, org.w3c.* etc, none of which are even in the jfxrt.jar
.
I can workaround this issue in two different ways
Neither of these methods is ideal as I have a large number of Eclipse projects to tweak, and would prefer the forbidden reference checks are left enabled to catch genuine errors.
Note this is also an issue when importing projects via the standard Gradle Import plugin included in Eclipse.
Is there anyway to avoid this issue, perhaps via Gradle configuration, or is a known bug/feature that will be fixed?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With