12

I have a fresh install of Java 8 (JDK 1.8.0_05 on Windows 7 32 bit) and Eclipse Luna. When I try to build a simple JavaFX program Eclipse shows the following message in the editor:

Access restriction: The type 'Application' is not API('C:\Program Files\Java\jre8\lib\ext\jfxrt.jar')

If I use the javac on the command line to compile the program every thing works fine.

Any hints how to solve this Problem?

greg-449
  • 109,219
  • 232
  • 102
  • 145
Klaus Rohe
  • 782
  • 2
  • 7
  • 11

4 Answers4

23

To access JavaFx in Java8 with Eclipse Luna (4.4):

Go to Build Path/ JRE/ Access rules/ Edit/ Add/ Accessible: javafx/**

Georg
  • 271
  • 2
  • 2
5

This solved the problem for me:

  • Opened the properties of the JRE of the Eclipse project using the context menu on the JRE
  • Instead of "Execution environment" I choose "Alternate JRE" and then "jdk1.8.0_5" - eventually you have to configure that "Alternate JRE" before
marc
  • 977
  • 9
  • 14
  • Thanks for this. In addition I configured the source attachment of "jfxrt.jar" to point to "C:/Program Files/Java/jdk1.8.0_25/javafx-src.zip" in "Java->Installed JREs". Now I'm getting somewhere :-) – Oliver Oct 26 '14 at 08:46
3

The e(fx)clipse project targets this issue, thanks a lot Tom Schindl:

http://www.eclipse.org/efxclipse/install.html

I have downloaded the nightly build SDK (which is based on 4.4RC3 at the moment):

http://downloads.efxclipse.bestsolution.at/downloads/nightly/sdk/
erdal.karaca
  • 693
  • 1
  • 4
  • 20
  • 4
    You can also install the plugin from the Eclipse Marketplace (current version 0.9.0. Kind of funny that this is required for an IDE explicitly targetting Java 8... – mmey Jul 03 '14 at 20:15
2

Finally , adding Access rules on ".classpath" file in eclipse project solved this issue for me.

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<accessrules>
            <accessrule kind="accessible" pattern="javafx/**"/>
        </accessrules>
    </classpathentry>   
jayalalk
  • 2,382
  • 3
  • 17
  • 14