'Java ClassVersionError although version seems to be okay
I'm getting the following error in my java web app (The application launches okay but when I click a button following error occurs). I'm using Tomcat (7.0.109) to run this application.
java.lang.UnsupportedClassVersionError: FileDetailsServlet 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 (unable to load class [FileDetailsServlet])
Previously I used Java 15 (class version 59.0). But then I switched to JDK and JRE 1.8.0_311 (class version upto 52.0)because of other 3rd party apps.
Here are some things that I did
- I've checked class version of FileDetailsServlet class using this
javap -verbose FileDetailsServlet| findstr "major"
command. And it shows that version is 51.0 (Java 7). - I've set JDK compliance to 1.8 in eclipse. (Project specific settings)
- After changing JDK I recompiled all the files using JDK 1.8.0_311
- I've checked environment variables. JAVA_HOME is "C:\Program Files\Java\jdk1.8.0_311" JRE_HOME is "C:\Program Files\Java\jre1.8.0_311" and Path is "C:\Program Files\Java\jdk1.8.0_311\bin"
Am I missing anything? I can not go back to Java 15. So is there any way around?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
