在 Eclipse Luna 中使用 JavaFX (JDK 1.8.0_05) 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24467931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:46:04  来源:igfitidea点击:

Using JavaFX (JDK 1.8.0_05) in Eclipse Luna does not work

eclipsejavafx-8eclipse-luna

提问by Klaus Rohe

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:

我全新安装了 Java 8(Windows 7 32 位上的 JDK 1.8.0_05)和 Eclipse Luna。当我尝试构建一个简单的 JavaFX 程序时,Eclipse 在编辑器中显示以下消息:

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

访问限制:'Application' 类型不是 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.

如果我在命令行上使用 javac 来编译程序,一切正常。

Any hints how to solve this Problem?

任何提示如何解决这个问题?

回答by Georg

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

使用 Eclipse Luna (4.4) 在 Java8 中访问 JavaFx:

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

转到构建路径/JRE/访问规则/编辑/添加/可访问:javafx/**

回答by marc

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
  • 使用 JRE 上的上下文菜单打开 Eclipse 项目的 JRE 的属性
  • 我没有选择“执行环境”,而是选择“备用 JRE”,然后选择“jdk1.8.0_5”-最终您必须在此之前配置该“备用 JRE”

回答by erdal.karaca

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

e(fx)clipse 项目针对这个问题,非常感谢 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):

我已经下载了 nightly build SDK(目前基于 4.4RC3):

http://downloads.efxclipse.bestsolution.at/downloads/nightly/sdk/

回答by jayalalk

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

最后,在eclipse项目中的“.classpath”文件上添加访问规则为我解决了这个问题。

<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>