找不到JavaFX包 [英] JavaFX packages not found

查看:2813
本文介绍了找不到JavaFX包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

import javafx.embed.swing.JFXPanel;

包javafx.embed.swing.JFXPanel不存在,对于任何其他fx包都是一样的。

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

当我使用 new project>创建项目时会发生这种情况。 java应用程序,但如果我尝试创建JavaFX示例,它可以工作......

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

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

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


  1. 我使用的是win7和jdk7(其中应包含java FX)

  2. 我在Netbeans中的项目(版本8)已选择JDK 1.7作为deafult库

  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 \\\\; C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ .7.0_17\jre\lib\jfxrt.jar

  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

我还应该做些什么呢?使JavaFX工作?感谢您的任何疑难解答...到目前为止,有关设置JavaFX的所有信息似乎都已过时。

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.

推荐答案

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

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

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

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.

这篇关于找不到JavaFX包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆