Unsupported Major.Minor Version 52.0

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 and JRE_HOME for Java 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.

ant Unsupported major.minor version 52.0

I see you have java 1.7 installed and post that you have installed Ant 1.10.

Ant 1.10 requires jdk 8
Refer : http://ant.apache.org/

The Apache Ant team currently maintains two lines of development. The
1.9.x releases require Java5 at runtime and 1.10.x requires Java8 at runtime. Both lines are based off of Ant 1.9.7 and the 1.9.x releases
are mostly bug fix releases while additional new features are
developed for 1.10.x. We recommend using 1.10.x unless you are
required to use versions of Java prior to Java8 during the build
process.

Try using Ant 1.9.x if you can't use java 8

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 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



Leave a reply



Submit