Intellij compiles JFX project with jdk13, produces JAR unable to be run with JRE 1.8 (Intellij Community 2019.3)
Answered
So I've created a JavaFX project which when I try to run from the Windows command line, produces this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: timingdiagram/TDraw has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
which unless I am mistaken means that I am attempting to run a JAR compiled with JDK 13 with JRE 1.8.
I would like to compile the project for JRE 1.8, but the -target option for the javac compiler (File > Settings > Compiler) doesn't work for me. I get this error on building the artifact:
Error:java: warning: source release 13 requires target release 13
So I tried to add JDK 1.8 to Intellij to no avail:
the selected directory is not a valid home for jdk
Please help! How can I create a runnable JAR compatible with Java 8 with IntelliJ?
Please sign in to leave a comment.
Hello,
What language level is set for project/module?
I had previously tried to build the artifact with these settings for javac but also with '-target 1.8' in the additional command line parameters:
and these for the project:

Upon building with language levels set to 8 and without any additional command line parameters, my JAR works.