简体   繁体   中英

How to install JavaFX on Ubuntu 20.04

I use Ubuntu 20.04 and i have 3 java versions installed:


  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-14-openjdk-amd64/bin/java      1411      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-14-openjdk-amd64/bin/java      1411      manual mode
* 3            /usr/lib/jvm/java-14-oracle/bin/java             1091      manual mode
  4            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 
$ java -version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

When I try to run the jar program through the terminal java -jar ***.jar , I still get the error

Error: JavaFX runtime components are missing, and are required to run this application.

And even when I change the version of Java, the error is still the same.

sudo apt-get install openjfx and sudo apt-get install openjfx-source - It doesn't work for me.

I do not understand how to install Java FX on Ubuntu 20.04. Do you have any advice for me? Please help.

JavaFX has been removed from JDK 11. So if are trying to run JavaFX app using JDK 11 or higher, you need to add all the JavaFX dependencies in your classpath. But if you try to run it with your Java 8, it may run just fine. Follow these instructions: https://openjfx.io/openjfx-docs/#install-javafx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM