I made a java program in Eclipse IDE (Version: 2019-09 R (4.13.0)) with multiple classes that is supposed to run in a terminal (cmd for example).
For this, I first tried to export my project: Export... > Runnable JAR file
I chose my Main class as my launch configuration and I clicked the radio button "Extract required libraries into generated JAR". I finished and the export seemed to work fine.
I know tried to run this program in cmd by using this attempt: https://stackoverflow.com/a/5774976/11583484 (java -jar fdm.jar
)
Now an error occurs:
Exception in thread "main" java.lang.UnsupportedClassVersionError: general/Main has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
At some point there seem to be trouble with Java versions, what may have been happened and what can I try to avoid it? I want to send the .jar file to another person that need to be able to run it properly later on.