While running selenium script, I am getting the following error message in Eclipse console:
Class has been compiled by a more recent version of the Java Environment (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0.
8
Eclipse Oxygen
46
To temporarily correct the problem do the following:
Project menu
> Properties
> Java Compiler
> Compiler compliance level
> 1.8
A permanent fix likely involves installing JDK 9.
FYI 1.8 is what Java 8 is called.
I recently returned to Java after a foray into C# (a breath of fresh air) and installed Eclipse Oxygen onto a clean system that had never had Java installed on it before. This default everything with a brand new install of Eclipse Oxygen yet somehow or other Eclipse can't get its own parameters to match the jdk that's installed. This is the second project I created and the second time I ran into this headache. Time to go back to C#?
has been compiled by a more recent version of the Java Runtime (class file version 53.0)
I had a similar issue from the console after building a Jar in Intellij. Using the Java configuration to update to a newer version (Windows -> Configure Java -> Update -> Update Now) didn't work and stuck at version 1.8 (Java 8).
To switch to a more recent version locally I had to install the Java 15 JDK from https://www.oracle.com/uk/java/technologies/javase-jdk15-downloads.html and add that to my Java runtime environment settings.
Your JDK version: Java 8
Your JRE version: Java 9
Here your JRE version is different than the JDK version that's the case. Here you can compile all the java classes using JDK version 1.8. If you want to compile only one java class just change the *.java
into <yourclassname>.java
javac -source 1.8 -target 1.8 *.java
source: The version that your source code requires to compile.
target: The oldest JRE version you want to support.
Go to Project section, click on properties > then to Java compiler > check compiler compliance level is 1.8 , or there should be no yellow warning at bottom
You can try this way
javac --release 8 yourClass.java
Refreshing gradle dependencies works for me: Right click over the project -> Gradle -> Refresh Gradle Project.
53
stands for java-9, so it means that whatever class you have has been compiled with javac-9
and you try to run it with jre-8
. Either re-compile that class with javac-8
or use the jre-9
For temporary solution just right click on Project => Properties => Java compiler => over there please select compiler compliance level 1.8 => .class compatibility 1.8 => source compatibility 1.8.
Then your code will start to execute on version 1.8.
I'm writing this because I found the other answers hard to understand.
Essentially your JRE is not updated and/or Eclipse is not configured to use the most recent JRE.
On Windows, go to Control Panel -> Programs -> Java -> update and proceed to update java
or if you don't have Java, go to Oracle's website and download the most recent JRE.
Once this is done, go into eclipse, and under the project view, right click on your project, select Java Build Path, double click on JRE System Library, then Select Workspace Default JRE 14.1.
If a recent version of Java doesn't show up here, it probably isn't installed. Check you JRE(NOT JDK) version and make sure it's recent. If it is, try restarting the computer then trying this again.
Source: Stackoverflow.com