When trying to use javafx related classes in my new java 8 project I get an access restriction error from eclipse. So far the only 'solution' I've been able to find is to tell eclipse to ignore the access restriction, but I am not satisfied with that. An example of the error:
Access restriction: The type Pane is not accessible due to
restriction on required library C:\Program Files\Java\jre8_0\lib\ext\jfxrt.jar
I'm using Eclipse Kepler with the Eclipse JDT patch for java 8.
This seems to be an issue related to the fact that JavaFX is not a part of the JavaSE execution environment.
I am now toughly confused as according to http://en.wikipedia.org/wiki/JavaFX javaFX is a part of the JavaSE. Is it possible that Eclipse is not recognizing that it is a part of the javaSE?
I've resolved this problem by some careful use of the Eclipse project's build path.
What this doing is making Eclipse see the jfxrt.jar as just a regular 3rd party JAR file. The order is important so that this takes precedence over the entry in the JRE system library. It's the same actual JAR file, but Eclipse is seeing it differently.
You may wish to alter any run configurations so it doesn't use the 'Exported' version of the jfxrt.jar; however in practical terms this won't make a difference.
I've done this with Java8 and Eclipse Luna; but the principal would I am sure work with any combination of Java and Eclipse.
under Libraries
Note: make sure that in Eclipse / Preferences (NOT the project) / Java / Installed JRE ,that the jdk points to the JDK folder not the JRE C:\Program Files\Java\jdk1.8.0_74
As James_D already suggested I added access rules to my classpath file. I uninstalled the e(fx)clipse plugin for the time being because it has a css validation bug (see How to disable css warning "Unknown property" in Eclipse Mars?).
Here is my entry in the classpath file for the JRE container:
I had the same problem. I used James_D 's solution but his exact solution did not work for me. But using
**/javafx/**
instead ofjavafx/**
solved the problem for me. Hope that helps.PS: I would post this as a comment under James_D 's solution but I just registered and did not have enough "reputation" to do so.
Step-1: Navigate to your jfxrt.jar. C:\Program Files\Java\jre1.8.0_111\lib\ext
Step-2 Copy the file jfxrt.jar
Step-3: Go to Eclipse,Create a new folder like this: [Creating folder name lib to put our jfxrt.jar file][2] [2]: https://i.stack.imgur.com/YsJ5S.png
Step-4: Select the lib folder and press CTRL+V to paste the jfxrt.jar [Paste your jfxrt.jar][1] [1]: https://i.stack.imgur.com/Ljogu.png
Step-5: Right click on jfxrt.jar and set as Build Path.