Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX packages not found

Tags:

java

javafx

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;

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

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

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.

like image 752
Smajl Avatar asked Jun 23 '14 08:06

Smajl


People also ask

Does JDK 17 support JavaFX?

JavaFX is not included in the JDK since Java 9 (with the exception of the Azul JDK, IIRC).

Does JDK 11 include JavaFX?

JavaFX is no longer included in the JDK. It is now available as a separate download from openjfx.io.

How do I fix JavaFX error?

If this is your case also, you can do fix this by simply right-clicking on the javaFX project folder-> Build Path-> Configure Build Path-> Select JavaFX SDK-> Remove library-> Select classpath -> add library-> user library-> select library-> apply. Save this answer.


1 Answers

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.

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.

like image 132
Mansueli Avatar answered Sep 30 '22 21:09

Mansueli