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

后端 未结 3 1292
旧巷少年郎
旧巷少年郎 2020-12-13 20:52

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-8u2         


        
相关标签:
3条回答
  • 2020-12-13 21:32

    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 ...)

    0 讨论(0)
  • 2020-12-13 21:44

    What I did was build it from source. The instructions here on the OpenJDK wiki worked for me. Once I built it, I had to put the jars in the right place, like this other stackoverflow post talked about.

    cd build/sdk/
    sudo cp -R rt/lib /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/
    sudo cp ./lib/ant-javafx.jar /usr/lib/jvm/java-8-openjdk-amd64/lib/
    sudo cp ./lib/javafx-mx.jar /usr/lib/jvm/java-8-openjdk-amd64/lib/
    

    After that I was able to compile my project!

    0 讨论(0)
  • 2020-12-13 21:54

    Use Oracle JDK (even if only as a temporary workaround)

    For any learners looking for a bit of basic practice with javafx, installing Oracle's Java 8 (which has javafx built-in) might be a better solution then messing about with open packages. There are great instructions here

    You can continue efforts getting openjfx installed, but this will keep your learning going.

    This has already been suggested by aran in a comment to the OP, please consider upvoting that comment.

    0 讨论(0)
提交回复
热议问题