Hot questions for Using Ubuntu in openjfx


When trying to compile an JavaFX application in the environment:

java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

cat /etc/lsb-release 

I get the error-message:

cannot access javafx.event.EventHandler
[ERROR]   class file for javafx.event.EventHandler not found

I tried to find a solution by following these links:

The most promising actions where to

  1. install openjfx with apt install openjfx
  2. set the JAVA_HOME environment variable to /usr/lib/jvm/java-8-openjdk-amd64

But the error persists.

What needs to be done to get OpenJDK 8 and JavaFX working on Ubuntu 18.04.2 LTS?


The hint from

helped. The commands:

apt purge openjfx
apt install openjfx=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2
apt-mark hold openjfx libopenjfx-jni libopenjfx-java

fixed the problem. Many thanks to for this. (If you'd like to answer this yourself I'll happily delete my own answer ...)


I wanted to use a specific version of openjfx so to download it I used the command

sudo apt install openjfx=8u161-b12-1ubuntu2

But intellij idea can't seem to find this file so i looked into it and when I searched for the file with the terminal command

find /usr -name jfxrt.jar

it came up with the location


but when I did

ls -la /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar

I got a response of

lrwxrwxrwx 1 root root 58 huhti   6  2018 /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar -> ../../../../../../share/java/openjfx/jre/lib/ext/jfxrt.jar

But the file location is red and I can't find it by going through my files in intellij. What does this mean? This isn't an issue with only this version of openjfx. I can't find the file even if I run just

sudo apt install openjfx

I'm running ubuntu 19.04 if that's of any help. Edit: Some more info if I click on the file jfxrt.jar through my graphical file manager it comaplains that "This link cannot be used, because its target "../../../../../../share/java/openjfx/jre/lib/ext/jfxrt.jar" doesn't exist." And when I made my way to the location that the link links to it ends in a dead ended at /share/java/openjfx where there was a few files. And in past tense, because now that I checked again there was nothing. Umm what. Idk if this helped at all, but hopefully someone could help me soon.


This was a massive pain to fix so if anyone else has this problem basically for some reason apt wasn't able to download all of the dependencies and I had to download libopenjfx-java which was found from so basically just run

sudo apt install libopenjfx-java=8u161-b12-1ubuntu2

That should fix the issue.


I want to write my first JavaFX 8 application (doing my first experiments with e(fx)clipse, etc.) and have a few concerns about platform independence.

JavaFX 8 is a part of the Oracle JRE, which is the most used JRE on Windows. Therefore, I do not really bother here, since JavaFX will be installed on nearly every Windows machine running Java 8.

But on Ubuntu and other *nix, OpenJDK is often used as Java distribution. Since openjfx is separated from open-jdk-8-*, many will not have JavaFX installed by default.

I thought of:

  • Writing an install script that calls sudo apt-get install openjfx (which I would like to avoid, since I would like the executable .jar to be runable on its own, without script)
  • Shipping a JavaFX distribution (i.e., its .jars) with my applications (but I read that this should not be done)

Both ideas do not seem very promising...

Since I hope that there are some JavaFX pros out there, i hope that someone can help me with "What are the best possibilities to ensure that my JavaFX application will run fine, both on Windows and Ubuntu?" What are state-of-the-art techniques on how to tackle this problem?


This page ( describes very well how to build a simple .deb package based on any directory structure (e.g., with precompiled stuff). You can than add your dependencies, e.g., to javafx packages, to the Depends section of the control file. ( This forces any installer like apt or dpkg to install javafx together with your package and makes them fail if this package is not available. You can also add a postinst script that will be executed after the installation in which you can set classpaths etc if necessary.


I have attempted to follow this solution, Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?, but is is unfortunately outdated. I did find the package openjfx I think I need here:

The package installs fine, under /usr/lib/jvm/java-8-openjdk-amd64/jre/lib and I can find jfxswt.jar and jfxrt.jar under the ext folder. The problem is that the java compiler does not know that they are here. I've tried explicitly pointing to their locations through the javac -cp and declaring the classpath in .bashrc. In both situations I declared them as such: ".:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar"

Upon compilation: javac -cp ".:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfxswt.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar"

Terminal Output: error: package javafx.application does not exist import javafx.application.Application;

So in short, I think I have done something wrong with the classpath and I would like to know how to get my compiler to recognize JavaFX. I hope I have provided enough information. I would prefer a solution not requiring the use of an IDE as I am trying to understand how to compiler handles these things. Thanks!


So, I did end up finding the answer, I should not have used openjdk-8. Perhaps I could have, but the better way I found was to download the version of Java 8u201 from Oracle's website.

This version contains the proper version of JavaFX and I simply pointed to this install using .bashrc and JavaFX works without any classpath issues, as it should.