Home > front end >  Error when run program in jvm 18: Java.lang.UnsupportedClassVersionError
Error when run program in jvm 18: Java.lang.UnsupportedClassVersionError

Time:08-08

i'm trying to run a project from Spring Initializr and I am getting the error java.lang.UnsupportedClassVersionError when I try to run the Main. The complete error is java.lang.UnsupportedClassVersionError: has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 55.0. The gradle is set to jvmTarget = 18 but aparrently when I put it to 11 it seem to fix the problem. I want to know why when I downgrade the version the program work.

CodePudding user response:

This error shows that you use older JRE version to run than to build. Your setup in gradle, you have to check what is your runtime version.

It seems you use IntelliJ. Go to File > Project Structure > Project > SDK - check if you have the Java 18 set here. You can also check in Run Configuration if there is proper JVM set.

Check also the JAVA_HOME env variable and set this variable to point to your recent JDK.

CodePudding user response:

I finally fixed the problem, I had to change the jetbrains runtime in project structure to the jdk 18 path. Aparently it fix the problem.

  • Related