Unsupported major.minor version 52.0 in java
This is because On your system javac
utility is pointing to Java 1.8
but java
utility is pointing to Java 1.7
.
To resolve it do following:
Note: I'm assuming that you are working on Windows OS
.
- In
PATH
variable, remove the very first path, if it looks like...\Oracal\javapath
- Set
JDK_HOME
andJRE_HOME
forJava 1.7
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
The version number shown describes the version of the JRE the class file is compatible with.
The reported major numbers are:
Java SE 18 = 62,
Java SE 17 = 61,
Java SE 16 = 60,
Java SE 15 = 59,
Java SE 14 = 58,
Java SE 13 = 57,
Java SE 12 = 56,
Java SE 11 = 55,
Java SE 10 = 54,
Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,
Java SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45
(Source: Wikipedia)
To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.
For example, in order to generate class files compatible with Java 1.4, use the following command line:
javac -target 1.4 HelloWorld.java
With newer versions of the Java compiler you are likely to get a warning about the bootstrap class path not being set. More information about this error is available in a blog post New javac warning for setting an older source without bootclasspath.
What does 'Unsupported major.minor version 52.0' mean, and how do I fix it?
You don't need to change the compliance level here, or rather, you should but that's not the issue.
The code compliance ensures your code is compatible with a given Java version.
For instance, if you have a code compliance targeting Java 6, you can't use Java 7's or 8's new syntax features (e.g. the diamond, the lambdas, etc. etc.).
The actual issue here is that you are trying to compile something in a Java version that seems different from the project dependencies in the classpath.
Instead, you should check the JDK/JRE you're using to build.
In Eclipse, open the project properties and check the selected JRE in the Java build path.
If you're using custom Ant (etc.) scripts, you also want to take a look there, in case the above is not sufficient per se.
Unsupported major.minor version 52.0 while trying to run an exe file
You need to install a Java 8 runtime as the application you downloaded was compiled with Java 8 as target platform.
Unsupported major.minor version 52.0 for when running junit
So I seem to have "solved" the problem by right clicking my project -> Properties -> Java Compiler -> Execution Environments -> JavaSE-1.7 (under Execution Environments) -> selected Java SE 8 under Compatible JREs
I got to Execution Environments via a hyperlink from a warning message at the bottom of the Java Compiler section which said:
When selecting 1.8 compliance, make sure to have a compatible JRE
installed and activated (currently 1.7). Configure the 'Installed
JREs' and 'Execution Environments', or change the JRE on the 'Java
Build Path'
I don't know what the regular route to Execution Environments option is, and I don't know why that seemed to have solved by issue, but I'm not running into the major.minor version error anymore.
Related Topics
How Can a String Be Initialized Using " "
Strings Are Objects in Java, So Why Don't We Use 'New' to Create Them
@Requestbody and @Responsebody Annotations in Spring
How to Get the Size of a Java.Sql.Resultset
Sparse Matrices/Arrays in Java
How to Sort List of Objects by Some Property
Why Does Changing the Returned Variable in a Finally Block Not Change the Return Value
How to Load Classes at Runtime from a Folder or Jar
How to Get Screen Resolution in Java
Jackson - Deserialize Using Generic Class
Using "Like" Wildcard in Prepared Statement
Java Sslhandshakeexception "No Cipher Suites in Common"
Why Do These Two Multiplication Operations Give Different Results
Java - Class.Getresource Returns Null
How to Handle Iframe in Selenium Webdriver Using Java
Jackson with JSON: Unrecognized Field, Not Marked as Ignorable