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 M
For Java Compiler 8 or above, do the following:
You will then be presented with the following screenshot below:
Make sure you have downloaded and installed a JDK 8 or above
When you press the finish button, all Java FX errors in your code should disappear.
Note Prerequisites:
JDK 9 installed and tested on NetBeans 8.0.1
Here's how to set it up on Ubuntu Linux with Maven:
1) Install OpenJFX package, check where did it put the files.
sudo apt install openjfx
dpkg-query -L openjfx
You might end up with version for JDK 11. In which case, either follow with installing a new OpenJDK, or set a version of OpenJFX for JDK 8.
2) Put it to your Maven project as a system
-scoped dependency.
Note this is the lazy and not-so-nice way. Properly, you should install the jars like this:
dpkg-query -L openjfx | grep -E '.jar$' | xargs -l -I{} \ mvn install:install-file -Dfile="{}" -DgroupId=javafx \ -DartifactId=$(echo $JAR | tr '.' '-') -Dversion=1.0 -Dpackaging=jar
And then use it as a normal
compile-scoped
dependency.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.source.level>1.8</project.source.level>
<project.target.level>1.8</project.target.level>
<javafx.dir>/usr/share/openjfx/lib</javafx.dir>
</properties>
<dependencies>
<!-- JavaFx :
sudo apt install openjfx
dpkg-query -L openjfx
-->
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-base</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.base.jar</systemPath>
</dependency>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-controls</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.controls.jar</systemPath>
</dependency>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.fxml.jar</systemPath>
</dependency>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.graphics.jar</systemPath>
</dependency>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-media</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.media.jar</systemPath>
</dependency>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-swing</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.swing.jar</systemPath>
</dependency>
<dependency>
<groupId>javafx</groupId>
<artifactId>javafx-web</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${javafx.dir}/javafx.web.jar</systemPath>
</dependency>
</dependencies>
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.
A) Make sure that you are using a compatible JDK, like 1.8, AND
B) configure a compatible version of Java in the Eclipse Project Facets.
For Java 11, this error also appears, as JavaFX has been removed from Java 11 and comes as standalone
More info: https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client-roadmap-updates