'File has been compiled by a more recent version of the Java Runtime error SceneBuilder

I've used JLink + JPackage to build a JavaFX app into a self-contained application. I'm using JDK 14. However, when I try to open one of my FXML files in IntelliJ's Scenebuilder I get this error:

File has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0.

To run the app in development environment, I use mvn clean javafx:run.

When I check in the IDE's compiler settings, the JDK is correctly set to 14, and so is the JAVA_HOME variable, as shown below. How do I fix this?

PS C:\dev> java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)


Solution 1:[1]

I'd say the problem are your custom components. You have probably compiled them with Java 14 and put the resulting jars into SceneBuilder. So each time when you load an FXML file which uses one of these components you will get that error message because the class file version of your components is younger than the version of SceneBuilder itself. For compatibility reasons it would be a good idea to compile your components with a target 11 anyway. You can do that with your Java 14 compiler. This would increase compatibility in general and solve your problem at hand.

Solution 2:[2]

I think (I'm not 100% sure but it makes sense) there are 2 answer's to this...

  1. Your intellij is using an older version of java (It can range from 6 to 13). So you would need to allow intellij to use a newer version of java (JDK14).
  2. Build your application with older version of java, of course you might need to change some functions because of older version of java.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 lukasLYU