未找到 JavaFX 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24361270/
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-08-14 11:47:38  来源:igfitidea点击:

JavaFX packages not found

javajavafx

提问by Smajl

I am trying to make a project with combined Swing and JavaFX components but JavaFX packages are not found by my IDE (tried with Netbeans and Eclipse).

我正在尝试使用组合的 Swing 和 JavaFX 组件创建一个项目,但我的 IDE 找不到 JavaFX 包(尝试使用 Netbeans 和 Eclipse)。

import javafx.embed.swing.JFXPanel;

says package javafx.embed.swing.JFXPanel does not exist, same for any other fx packages.

package javafx.embed.swing.JFXPanel does not exist,对于任何其他 fx 包也是如此。

This happens when I create project using new project > java application, but if I try to create JavaFX sample, it works...

当我使用创建项目时会发生这种情况new project > java application,但是如果我尝试创建 JavaFX 示例,它会起作用...

I have no idea what am I missing here. Here are some background information and steps I have tried:

我不知道我在这里错过了什么。以下是我尝试过的一些背景信息和步骤:

  1. I am using win7 and jdk7 (in which java FX should be included)
  2. My project in Netbeans (version 8) has JDK 1.7 selected as a deafult library
  3. I updated my path: JAVA_HOME: C:\Program Files\Java\jre7
  4. And also system Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\DMIX;C:\Program Files\Java\jdk1.7.0_17\jre\bin;C:\Dev\ant\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0_17\jre\lib\jfxrt.jar
  1. 我正在使用 win7 和 jdk7(其中应包含 java FX)
  2. 我在 Netbeans(版本 8)中的项目选择了 JDK 1.7 作为默认库
  3. 我更新了我的路径: JAVA_HOME: C:\Program Files\Java\jre7
  4. 还有系统路径: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\DMIX;C:\Program Files\Java\jdk1.7.0_17\jre\bin;C:\Dev\ant\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0_17\jre\lib\jfxrt.jar

What else should I do to make JavaFX work? Thanks for any troubleshooting... All the information about setting JavaFX so far seem to be very outdated.

我还应该怎么做才能使 JavaFX 工作?感谢您的任何故障排除...到目前为止,有关设置 JavaFX 的所有信息似乎都非常过时。

采纳答案by Mansueli

You must include in the Project in your IDE the jfxrt.jarotherwise it will not be included as this was the default behavior prior to Java 8.

您必须在 IDE 的项目中jfxrt.jar包含它,否则它不会被包含,因为这是 Java 8 之前的默认行为。

Then depending on your system and the way your build your jar for your project, and it also must be there for running the jar. So make your project also export the required libraries.

然后根据你的系统和你为你的项目构建 jar 的方式,它也必须在那里运行jar. 所以让你的项目也导出所需的库。