Good morning everyone. I read many posts related to this problem but the solution is not clear. I Just bought a new laptop, installed the last version of JDK, and wrote a simple "Hello world" java program in order to see if everything was ok with compiling and executing. So, compiling is fine, the file .class is created, but when I try to execute, it displays this:
Exception in thread "main" java.lang.UnsupportedClassVersionError: File1 has been compiled by a more recent version of the Java Runtime (class file version 59.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(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I think I already found the problem, I'm just here to confirm: In addition to the JDK v15.0.1, I also installed a JRE v1.8.0_271 in order to play some games which require a specific installation of the JRE manually (Minecraft for example). I suspect that JAVA is compiling with the JDK 15.0.1 (of course), BUT then it tries to execute it with JRE 1.8... That's why, maybe, it displays a version error... May someone confirm or disprove what I said?
(I suspect this because if it's only JDK's fault, How could they implement a JDK which can compile but not execute its own programs? xD)