Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install openJDK+openJFX 8 on Ubuntu 20

I'm trying to install OpenJDK 8 and OpenJFX 8 on Ubuntu 20.10.

Installing openJFX 8 has always been a little tricky on Ubuntu, but I used to be able to do it using the tip from this SO answer: https://stackoverflow.com/a/56166582/2423283 That used to work fine (I think I was using Ubuntu 19.something), however it appears that recently 8u161-b12-1ubuntu2 was removed.

For some more background information, I'm installing this via a docker file in an automated pipeline. Here are the relevant parts of the Dockerfile:

FROM my.company.internal.registry:443/ubuntu:latest

RUN apt -y update && \
    apt -y install \
    openjdk-8-jdk \
    openjfx=8u161-b12-1ubuntu2 \
    libopenjfx-java=8u161-b12-1ubuntu2 \
    libopenjfx-jni=8u161-b12-1ubuntu2

This used to run just fine, but now I get:

E: Version '8u161-b12-1ubuntu2' for 'openjfx' was not found
E: Version '8u161-b12-1ubuntu2' for 'libopenjfx-java' was not found
E: Version '8u161-b12-1ubuntu2' for 'libopenjfx-jni' was not found

What I've tried so far

I've tried changing my ubuntu:latest to ubuntu:19:10 in my FROM line in the Dockerfile, but I still got the missing packages errors.

I tried just removing those version restrictions (the =8u161-b12-1ubuntu2) and I didn't see any errors during the installation, but then when I compiled my code, none of the JavaFX classes could be found.

like image 895
NateW Avatar asked May 13 '20 19:05

NateW


2 Answers

I stumbled upon the same problem and found that the easiest solution is to use sdkman: https://sdkman.io/install

With these three commands I was able to have openjdk 8 with JavaFX installed on Ubuntu 20.04:

curl -s "https://get.sdkman.io" | bash

source "$HOME/.sdkman/bin/sdkman-init.sh"

sdk install java 8.0.252.fx-zulu

like image 63
user1822128 Avatar answered Sep 20 '22 04:09

user1822128


If you are set on using JDK 8 and JavaFX, I've found it's best to install an OpenJDK that includes JavaFX.

For version 8, not all OpenJDKs include JavaFX (e.g. AdoptOpenJDK). The best ones I have found are

  • Zulu : You must select "JDK FX" in the Java Package drop down
  • Liberica: You must select "Full JDK"

Liberica provides builds for raspberry pi and a wide variety of other architectures. If you need that, Liberica is the way to go.

like image 36
maroc Avatar answered Sep 18 '22 04:09

maroc