Using JavaFX in JRE 8, “Access restriction” error

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'm going to add one more answer here, just to provide what I think is the most minimal approach. In my Eclipse setup, I have e(fx)clipse installed, which provides one fix for this, as well as providing many useful development features that you will almost certainly want if you are writing JavaFX applications. This is probably the most practical approach. If for some reason you don't want that plugin, the solution outlined in this answer will fix the problem with the least amount of other side effects.

As pointed out in other answers, Eclipse, by default, disallows access to classes in jar files in the jre/lib/ext directory, as these are not guaranteed to be present on all Java platforms. If you are writing a JavaFX 8 application, you are assuming you are on a platform where jfxrt.jar is available in the lib/ext location.

So the minimal fix for this is to allow access to the classes in this jar file (and only in this jar file). To do this, right-click on the project and bring up the project properties dialog. Select "Build Path" in the left pane, and select the "Libraries" tab. You will see a "JRE System Library" entry. Expand that entry, and you will see an "Access Rules" subentry:

enter image description here

Select the "Access Rules" entry and click "Edit". Click "Add".

enter image description here

Under "Resolution", choose "Accessible", and under "Rule Pattern", enter javafx/**:

enter image description here

Click OK to exit all the dialogs.

This setting will allow access to all the classes in any packages beginning javafx., but will preserve the rule on the ext folder for all other classes, and is "minimal" in that sense.

Again, what you probably really want to do is to install the e(fx)clipse plugin, but to my knowledge this is the solution with the least side effects on your Eclipse setup.


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


I resolved the problem by removing and readding the JDK to the build path. Don't ask me why this works, though.


The easy way is to install e(fx)clipse - a plugin for Eclipse to support JavaFX:

  1. Select Help -> Install New Software
  2. Click Add button to add the following site:
    • Name: efxclipse
    • Location: http://download.eclipse.org/efxclipse/updates-released/1.2.0/site
  3. Click OK
  4. In the "Work with", select the recently added site "efxclipse"
  5. Check the checkbox "e(fx)clipse - install" to install all components of this selection
  6. Move to next steps to finish the installation
  7. Restart your Eclipse. If it still doesn't recognize JavaFX library, restart it again.

Original information can be found here: https://www.eclipse.org/efxclipse/install.html#for-the-lazy


I've resolved this problem by some careful use of the Eclipse project's build path.

  • Bring up the properties of the you application project and select the 'Build Path' section.
  • Add the jre8_0\lib\ext\jfxrt.jar as an "External JAR file" in the 'Libraries' tab.
  • In the 'Order/Export' tab ensure that this jfxrt.jar is first in the list.

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.