Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Java FX running with OpenJDK 8 on Ubuntu 18.04.2 LTS?

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 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

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:

  • how to add javafx dependencies in maven with java 10
  • https://mvnrepository.com/artifact/org.openjfx/javafx/11
  • Maven project with JavaFX (with jar file in `lib`)
  • https://github.com/javafx-maven-plugin/javafx-maven-plugin
  • https://askubuntu.com/questions/1091157/javafx-missing-ubuntu-18-04
  • https://unix.stackexchange.com/questions/505628/add-openjfx-class-path-in-debian-for-java11
  • https://askubuntu.com/questions/609951/javafx-is-not-on-the-default-classpath-even-with-oracle-jdk-1-8
  • Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?
  • http://can4eve.bitplan.com/index.php/JavaFX

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?

like image 237
Wolfgang Fahl Avatar asked May 16 '19 10:05

Wolfgang Fahl


People also ask

Is JavaFX included in OpenJDK 8?

There are org. openjfx artifacts for OpenJFX 11 onwards, but they won't work with Java 8.

Does JDK 8 support JavaFX?

JavaFX is included in Oracle JDK 8 running on OS X, Linux x86 and Windows. The best place to learn more about this is the Oracle Client Technologies documentation for JavaFX.

How do I enable JavaFX?

Install the Standalone JavaFX Runtime Verify your system requirements. Go to the JavaFX Downloads page. Find the JavaFX Runtime downloads, click the link for your operating system, and follow the prompts to save the executable file. Run the .exe file.


1 Answers

The hint from

https://github.com/JabRef/help.jabref.org/issues/204

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 https://github.com/Druidefix for this. (If you'd like to answer this yourself I'll happily delete my own answer ...)

like image 135
Wolfgang Fahl Avatar answered Sep 25 '22 08:09

Wolfgang Fahl