Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The import javafx cannot be resolved

I installed Eclipse IDE today on my Ubuntu Linux and then installed JavaFX using 'Install New Software' and when I created a javafx project, I got the following error in Main.java:

The import javafx cannot be resolved.

So, I listed the following directory to search for "jfxrt.jar":

ls -l /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext

But I didn't find "jfxrt.jar".

java -version

The output:

openjdk version "1.8.0_45-internal"

OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)

OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

like image 743
Farouk Sabry Avatar asked Sep 17 '15 12:09

Farouk Sabry


People also ask

Why is JavaFX not working in Eclipse?

The project doesn't support the JavaFX syntax. We need to export the JavaFX jar files to the project in order to run the JavaFX application. Just Right click on the project and select properties from the options. Go to Java Build Path → Libraries.


1 Answers

According to the packages list in Ubuntu Vivid there is a package named openjfx. This should be a candidate for what you're looking for:

JavaFX/OpenJFX 8 - Rich client application platform for Java

You can install it via:

sudo apt-get install openjfx

It provides the following JAR files to the OpenJDK installation on Ubuntu systems:

/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/ant-javafx.jar
/usr/lib/jvm/java-8-openjdk-amd64/lib/javafx-mx.jar

Hope this helps.

like image 71
MWiesner Avatar answered Sep 21 '22 11:09

MWiesner