0

I created demo application of Spring boot, and now try to run generated jar file, but I get the following error

C:\Users\User\Downloads\demo\target>java -jar demo-0.0.1-SNAPSHOT.jar Exception in thread "main" java.lang.UnsupportedClassVersionError: com/example/demo/DemoApplication has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

My Jre version is 1.8.0_271, java was configure in pom.xml to be 11. jdk version is 14.0.1. I tried to change java version in pom to 8, but then some 11 version related functionality doesn't work. How can this mismatch be resolved?

dpr
  • 10,591
  • 3
  • 41
  • 71
  • 1
    You cannot use newer Java features on older JREs. If you want to use Java 11 features you need a version 11 JRE. – Jeroen Steenbeeke Oct 26 '20 at 08:50
  • How can I download 11 JRE? – Gio Dos Santos Oct 26 '20 at 09:05
  • Have a look at https://adoptopenjdk.net/ – dpr Oct 26 '20 at 09:08
  • @dpr your link worked. I downloaded 11 version and run from this directory, now the error is gone. one question, how to make IntelliJ terminal run this particular java.exe from AdoptOpenJDK folder? so that I dont type the entire path to the exe file every time. Now when i just type java -jar filename, the problem of mismatch still persists – Gio Dos Santos Oct 26 '20 at 09:21
  • Should be somewhere the project settings. Just search for JDK or JRE and you'll probably find the right place – dpr Oct 26 '20 at 10:39
  • after restarting computer it worked, before that installer change JAVA_HOME environment variable to the new directory of installation. – Gio Dos Santos Oct 28 '20 at 11:48

0 Answers0