Eclipse 无法识别 JavaFX
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15592775/
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
JavaFX is not recognized in Eclipse
提问by Matt
JavaFX is supposed to be included with the latest release of the JDK. I'm using 1.7 v 17. Imports like:
JavaFX 应该包含在最新版本的 JDK 中。我正在使用 1.7 v 17. 导入如下:
import javafx.fxml.Initializable;
are not recognized. I would prefer not to have to link to the jar manually.
不被认可。我宁愿不必手动链接到 jar。
I heard that this was a bug before, but that it should have been fixed. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7166330
我之前听说这是一个错误,但应该已经修复了。http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7166330
Does anyone have an answer on how javafx can be recognized. I don't want to have e(fx)clipe do it for me and I don't want to have to link the jar. As far as I understand, it;s now included in the latest release of the jdk, therefor I should be able to do an import like above right?
有没有人有关于如何识别 javafx 的答案。我不想让 e(fx)clipe 为我做这件事,也不想链接 jar。据我了解,它现在包含在最新版本的 jdk 中,因此我应该能够像上面那样进行导入,对吗?
采纳答案by tomsontom
JavaFX isn't on any of the default classpaths in JDK7 - please see in which version the bug has been fixed!
JavaFX 不在 JDK7 中的任何默认类路径上 - 请查看已修复该错误的版本!
In JDK8 this is fixed and JavaFX is on the ExtensionClasspath but still you'll get warnings from Eclipse because stuff on the extension classpath is considered an implementation detail - you'll can fix this yourself in the JRE-Runtimes.
在 JDK8 中,这是固定的,JavaFX 位于 ExtensionClasspath 上,但您仍然会收到来自 Eclipse 的警告,因为扩展类路径上的内容被视为实现细节 - 您可以在 JRE-Runtimes 中自行修复此问题。
What's your problem with e(fx)clipse? It would fix all your problems no matter if you develop against JDK7 or JDK8?
e(fx)clipse 有什么问题?无论您是针对 JDK7 还是 JDK8 进行开发,它都能解决您的所有问题吗?
回答by ZiglioUK
On Ubuntu 14.10 I had to install first openjfx
在 Ubuntu 14.10 上,我必须先安装 openjfx
sudo apt-get install openjfx
then I created a default project using e(fx)clipse and the default JRE (java-8-openjdk-amd64).
然后我使用 e(fx)clipse 和默认 JRE (java-8-openjdk-amd64) 创建了一个默认项目。
回答by AxxG
You can add the "jfxrt.jar" manually! Its in the installed JDK. Example:
您可以手动添加“jfxrt.jar”!它在安装的JDK中。例子:
- Windows XP: "C: \ Program Files \ Java \ jdk1.7.0_17 \ jre \ lib \ jfxrt.jar"
- Windows 7 (32 bit): "C: \ Program Files (x86) \ Java \ jdk1.7.0_17 \ jre \ lib \ jfxrt.jar"
- Windows 7 (64 bit): "C: \ Program Files \ Java \ jdk1.7.0_17 \ jre \ lib \ jfxrt.jar"
- Windows XP:“ C:\Program Files\Java\jdk1.7.0_17\jre\lib\jfxrt.jar”
- Windows 7(32 位):“ C:\Program Files (x86)\Java\jdk1.7.0_17\jre\lib\jfxrt.jar”
- Windows 7(64位):“ C:\Program Files\Java\jdk1.7.0_17\jre\lib\jfxrt.jar”
Copy the jar file and put it to a subfolder in the project (for example, / lib).
将jar文件复制到项目中的子文件夹中(例如/lib)。
Now add the "jfxrt.jar" to the classpath. Click the right mouse button on the project and select from Properties -> Java Build Path -> Libraries -> Add JARs from ... and add the jar file.
现在将“jfxrt.jar”添加到类路径中。在项目上单击鼠标右键,然后从 Properties -> Java Build Path -> Libraries -> Add JARs from ... 中选择并添加 jar 文件。