示例“mavenproject”netbeans 7.4 不存在包 javafx
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19577995/
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
package javafx does not exist for sample "mavenproject" netbeans 7.4
提问by Tom D
I am trying to run the "mavenproject1" file created by doing a "File::new project" and selecting "maven" then "JavaFX Application".
我正在尝试运行通过执行“File::new project”并选择“maven”然后选择“JavaFX Application”创建的“mavenproject1”文件。
I am using the latest and greatest. I have Java JDK 1.7.0_45 which I installed separately that is configured to build the project. I have Netbeans 7.4 (Build 201310111528) with MAVEN 3 built in. JavaFX is bundled with the JDK 1.7.0_45.
我正在使用最新和最好的。我有单独安装的 Java JDK 1.7.0_45,它被配置为构建项目。我有内置 MAVEN 3 的 Netbeans 7.4 (Build 201310111528)。JavaFX 与 JDK 1.7.0_45 捆绑在一起。
I can make the project execute, but my source files get an error indicating that the JavaFX package does not exist. I added the following to my pom.xlm file which allows Maven to build and execute the source files even though the NB editor cannot find the JavaFX packages:
我可以让项目执行,但我的源文件收到一个错误,表明 JavaFX 包不存在。我在 pom.xlm 文件中添加了以下内容,即使 NB 编辑器找不到 JavaFX 包,它也允许 Maven 构建和执行源文件:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${java.home}\lib\jfxrt.jar</systemPath>
</dependency>
How can I get the NB editor to recognize the JavaFX packages?
如何让 NB 编辑器识别 JavaFX 包?
采纳答案by jewelsea
If you can, I advise using Java 8as:
如果可以,我建议将Java 8用作:
- JavaFX is on the default Java classpath in Java 8 but not in Java 7.
- As JavaFX is on the default Java 8 classpath, you don't need a system path dependency on jfxrt.jar in your maven project.
- As JavaFX is on the default Java 8 classpath NetBeans 7.4 should recognize JavaFX packages with no extra configuration.
- JavaFX 位于 Java 8 中的默认 Java 类路径上,但不在 Java 7 中。
- 由于 JavaFX 位于默认的 Java 8 类路径上,因此您的 maven 项目中不需要对 jfxrt.jar 的系统路径依赖。
- 由于 JavaFX 在默认的 Java 8 类路径上,NetBeans 7.4 应该无需额外配置即可识别 JavaFX 包。
You may also want to consider using the javafx-maven-plugin.
您可能还需要考虑使用javafx-maven-plugin。