6

I am trying to use openjdk-11 on ubuntu, but my project requires javafx.

There is an openjfx package but it installs alognside with openjdk-8.

So far I only found instructions to build both openjdk and openjfx from scratch.

Any easier way?

Edit: openjdk-11 comes without javafx/openjfx by default.

  • You can have multiple java versions installed, and choose version with sudo update-alternatives --config java. All versions must be present in /etc/alternatives/ . Example : sudo update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_162/bin/java 2 – Knud Larsen May 14 '18 at 14:54
  • Thanks Knud, but it does not solve the problem. I have openjdk-11 as the selected alternative, but it does not have javafx/openjfx. – Thiago Sayão May 14 '18 at 15:42
  • "openjfx" : sudo apt install openjfx openjfx-source ... Plenty of plugins, no executable. https://packages.ubuntu.com/search?keywords=openjfx 1. https://packages.ubuntu.com/bionic/amd64/openjfx/filelist 2. https://packages.ubuntu.com/bionic/all/libopenjfx-java/filelist 3. https://packages.ubuntu.com/bionic/amd64/libopenjfx-jni/filelist 4. https://packages.ubuntu.com/bionic/all/openjfx-source/filelist – Knud Larsen May 14 '18 at 16:53
  • 1
    @KnudLarsen: openjfx has a dependency on openjdk-8-jre. So I don't think you are really using it with openjdk-11. – chrish Aug 08 '18 at 21:04
  • So JavaFX seems to be published in maven repositories now. Is the jdk11 way to declare dependencies in build files (like with Gradle)? Can we get an answer to this question describing this? (EG javafx-graphics seems to contain the javafx.application.Application class) ... Can these packages also be installed through package managers? – Travis Well Apr 30 '19 at 23:14

3 Answers3

5

First, install OpenJFX:

sudo apt install openjfx

You can then add these arguments to any java invocation:

--module-path /usr/share/openjfx/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web
4

I figured it out:

You have to download the latest build from the openjfx web site an run as described here: http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-May/021819.html

It seems to have gtk3 enabled by default wich did not seem as stable as gtk2. So for now I have decided to stick with oracle 10 jdk and wait for openjfx to mature and have maven packages.

0

According to the official documentation:

With the module system in JDK 9 and later, it is not possible to easily overlay an OpenJFX build over an existing JDK as was possible with JDK 8. It is possible to build an OpenJDK that included the updated OpenJFX modules.

Therefore you either need to wait for an incoming standalone installer with JDK 11 or you have to build OpenJDK with OpenJFX from scratch.

rzo
  • 101