0

I tried to run my Gitlab code on Command Prompt, but it failed. I was using Gradle, and it said "java.lang.UnsupportedClassVersionError: org/openjfx/gradle/JavaFXPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0"

I have Java 8 and JavaFX 11 installed. Should I download Java 11? But, I heard that some of my friends had a hard time installing JavaFX because they're using Java 11. Is there any other way to fix this? I'm a total noob in programming, can someone help me?

1 Answers1

0

Firstly you have to know that JavaFX is not longer included in the SDK. The problem is that you have chosen the wrong Java version for the FX project. I recommend you to download a newer Java version. I'm currently using Java 11 with JavaFX 11. The problem is that you have to specify VM arguments and link the JavaFX Modules you need. Here is my result how I setup JavaFX 11 and Java 11

This documentation is just for Windows!! In addition I use IntelliJ for my projects

  1. Download and install Java 11

  2. Download JavaFX from https://gluonhq.com/products/javafx/

  3. create a folder named .jdk or whatever you want in C:\Users\YOUR USER, paste the Openjfx zip in there and unzip it. You can set the folder wherever you want but set it there where you can find it again easily.

  4. Set Java Version in IntelliJ: Click on File -> Project Structure -> Project and select Java 11

  5. Set Java Version for Gradle: Click on File -> Settings -> Build Execution Deployment -> In window choose Gradle JVM

  6. Set VM Options as followed: --module-path /path/to/javafx/sdk --add-modules javafx.controls,javafx.fxml

You can add more modules by separating them with a "," For this also see: https://www.jetbrains.com/help/idea/javafx.html#vm-options

That's how I setup JavaFX on Java 11. When it comes to providing Jar for outside use, you have to start it with the VM Options too. Except you created a Jar which already has the modules included see Jlink docs.

Erik
  • 1
  • 1