How to resovle Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 error?

Viewed 43549

I am trying to run a Spring Boot app in IntelliJ.

But when I try to run I get the following error message:

Exception in thread "main" java.lang.UnsupportedClassVersionError: myProject 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

Here is the JRE location under my Run Configuration:

enter image description here

I have tried installing a couple of different Java versions here:

enter image description here

Here are my current system / environment variables:

Environment Variables:

JAVA_HOME: C:\Program Files\Java\jdk-11.0.12\bin

System Variables:

Path: C:\Program Files\Java\jdk-11.0.12\bin ....

I tried to find a JRE that matched the version, but haven't been able to find it.

Can someone please tell me what changes I need to make so I can successfully run this application locally?

2 Answers

If you are trying to execute the code outside your IDE...

The problem is Windows....

Open your command prompt and type "where java". When you do this, you will notice a "weird" path that looks something like this

C:\Program Files\Common Files\Oracle\Java\javapath\java.exe

I can't recall what Windows version introduced this shortcut, but I want to say it was Windows 7. The problem is that this shortcut points to a Runtime Environment that is more recent (newer) than the Java version that was used to compile the code. In other words, Java is backwards compatible; not forward compatible. Compiled code cannot run in a newer Java version.

How do you fix this?

One way is to go to your SYSTEM Environment Variables and edit the Path system variable and add JAVA_HOME at the very beginning of the paths. It will be something like this

%JAVA_HOME%; {YOUR OTHER PATHS HERE}

If you are trying to execute within the IDE, the problem is similar. POTENTIALLY, you can have a conflict between your PROJECT properties and your global IDE properties, where the Runtime Environment points to a newer version of Java than the JDK used to compile. That said...

I have a very weird issue with an application I worked on years ago. It was a client/server application and a coworker of mine was having this issue because, unbeknownst to her, there was version of the server running in the background that was causing the conflict. So, if you have a similar type of application, check your processes using Task Manager and make sure you either 1) shutdown this application and try again, or 2) Uninstall that application and reinstall the new one. In her case, she tried rebooting her PC but that didn't work because the process would start automatically after each reboot.

Related