I have a recent Eclipse (2022-03) which relies on some JRE-17 according to eclipse.ini (-vm C:/Users/ericl/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.2.v20220201-1208/jre/bin), but I still want to use a JDK/JRE 1.8 which seems to be correctly installed everywhere (Eclipse preferences installed JRE, JDK compliance 1.8, etc...) because I want to build a standalone executable JAR for an older JavaFX lib because it relies on a single file (jfxrt.jar), so it is obviously easier to distribute.
I use "ant -v" to build my JAR to be sure I rely on the correct JRE 1.8: Apache Ant(TM) version 1.10.12 compiled on October 13 2021 Trying the default build file: build.xml Buildfile: C:\Development\java\eclipse\workspace\MCQ Factory JavaFX\build.xml Detected Java version: 1.8 in: C:\Development\java\jdk1.8.0_121\jre ...
Javac correct: javac -version javac 1.8.0_121
Java correct: java -version java version "1.8.0_121"
But when I try to execute my standalone JAR "MCQ-Test.jar" I get the UnsupportedClassVersionError although JDK 1.8 seems to have been used all along: java -jar .\MCQ-Test.jar Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: com/fdli/mcq/logic/McqPlayer has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
So how can I force the compilation of my standalone JAR to the correct version?