JavaFX packages not found

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

import javafx.embed.swing.JFXPanel; 

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

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

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

  • I am using win7 and jdk7 (which should include java FX)
  • My Netbeans project (version 8) has JDK 1.7 selected as the deafult library.
  • I updated my path: JAVA_HOME: C:\Program Files\Java\jre7
  • And also the 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

What else should I do to get JavaFX working? Thanks for any troubleshooting ... All information about installing JavaFX so far looks very outdated.

+6
source share
1 answer

You must include jfxrt.jar in your project IDE, otherwise it will not be included, as this was the default behavior before Java 8.

Then, depending on your system and the method of assembling your jar for your project, it should also be there to run jar . Thus, your project also exports the necessary libraries.

+4
source

Source: https://habr.com/ru/post/971221/


All Articles