Can't fix Unsupported major.minor version 52.0 even after fixing compatibility
Asked Answered
C

13

35

When I try running my java .jar on another machine I get the error

Unsupported major.minor version 52.0

I compiled my program using the jdk 1.6 and my machine (separate one) has java 7 installed.

This is the java version my machine is running:

java version 1.7

Here are the settings in my IDE (Eclipse Lunar)

eclipse compiler settings

eclipse JRE settings

Why am I still getting an unsupported error?

I did check my run configuration and change it to jre6, but when I do I can't even run my program in the IDE.

Note: I would like my program to work with jdk 6, if that is not possible jdk 7.

My Class Path:

class path

Coralloid answered 16/7, 2014 at 21:10 Comment(6)
"I compiled my program using the jdk 1.6" No, you didn't. You used 1.8.Genni
I changed the jre version and tried building but it wont even run in my IDE. Can you help me compile using 1.6?Coralloid
You might find it easiest to only have a JDK 1.6 on your machine.Viguerie
Change your compiler options to specify target version 1.6. Recompile everything.Authorization
You might have other classes outside your project which you have not recompiled.Viguerie
Does the project also specify the right compiler compliance if it's specifying one?Fransis
I
33

I agree with chrylis: you believe you changed your project's compliance settings but probably you didnt.

Right click on your project and:

  • Java / Build Path : Go to Libraries tab and ensure yourself that you are really using jre6
  • Java / Compiler : Ensure yourself that you have selected 1.6 compliance

By the way you can "tell" eclipse that jre8 is 1.6 compliance clicking on Window/Preferences/Java/Installed JREs/Execution Environment and selecting in the left panel, Execution Environments, JavaSE-1.6 and in the Compatible JRE's panel, jre8

Invagination answered 16/7, 2014 at 22:12 Comment(1)
And, to be sure, you can use javap to dump a .class file compiled with the settings.Authorization
F
14

Hi I found this link that helped me understand the issue. Hope it is useful. Version released so far are

  • 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

and from thata data it simply means

Many people think why do you get a version mismatch error if Java is backward compatible. Well, its true that Java is backward compatible, which means you can run a Java class file or Java binary (JAR file) compiled in lower version (java 6) into higher version e.g. Java 8, but it doesn't mean that you can run a class compiled using Java 7 into Java 5, Why? because higher version usually have features which are not supported by lower version.

Sometimes you may have more than one version of Java installed in you machine. Make sure the application you are running is pointing to the right or highest version available.

Fraser answered 24/3, 2016 at 8:17 Comment(0)
D
2

I Encounter similar issue while doing development on Android Studio 2.2.

My Machine Configuration -

  1. JDK version 1.7.0_79 installed
  2. JDK version 1.8.0_101 installed
  3. Environment variable contains : JAVA_HOME = 1.7.0_79 JDK path and same is added to path variable
  4. Project SDK Location = C:\Program Files\Java\jdk1.8.0_101

I then made below changes - 1. Uninstall JDK 1.7.0_79 2. Updated JAVA_HOME = 1.8.0_101 JDK path (Similar to SDK Location)

Now i am able to compile and run my application successfully , no more Unsupported major.minor version 52.0 Error

Drugi answered 30/8, 2016 at 11:25 Comment(0)
F
1

If you are trying to execute your program/application from the command prompt. Just make sure to restart your cmd after you have changed the JAVA_HOME var. Very simple but easily missed sometimes.

Flyer answered 3/7, 2017 at 10:15 Comment(0)
M
0

Several possiblies that causes this problem. The root cause is mismatched of compiler version between projects and IDE. For windows environment you can refer to this blog to do the detail troubleshooting.

Minna answered 15/4, 2015 at 4:18 Comment(0)
R
0

The error happens when you have compiled with higher version of Java and it is been tried to run with lower version of JRE. Even with minor version mismatch you would have this issue

I had issue compiling with JDK 1.8.0_31 and it was run with jdk1.8.0_25 and was displaying the same error. Once either the target is updated to higher version or compiled with same or lesser version would resolve the issue

Retrogressive answered 19/6, 2015 at 20:48 Comment(0)
S
0

Are you using retrolambda? If so, just do JAVA_HOME=$JAVA8_HOME.

Source: https://github.com/evant/gradle-retrolambda/issues/74

Seditious answered 10/3, 2016 at 4:28 Comment(0)
O
0

Its a silly problem, just make sure that the jdk and jre are latest version. This problem mainly occurs due to the automatic update of java(jre) and the jdk is not supported to that version, this makes problem.

Oleson answered 29/4, 2016 at 11:22 Comment(0)
M
0

Right Click on Project, Properties ---> Java Compiler ( on same page change compiler Compliance Level to 1.6 (or) 1.7 (or) 1.8 ( match with your JAVA_HOME)

Micronesia answered 30/8, 2016 at 15:59 Comment(0)
L
0

First of all thank you for all above answers. However, I use Intellij Idea for daily basis. So, I hope my answer will help others.

Run your favourite terminal or command line. Then check your java version by running command

java -version

Then in Intellij press

Ctrl+Alt+Shift+S

in the

Project Settings

tab under

Project SDK

choose appropriate java version. Lastly, rerun your code.

Libenson answered 6/3, 2017 at 17:24 Comment(0)
P
0

I had also same issue. I solved this problem by updating my system jdk. Previously i used jdk7.0 and now it is updated to jdk8.0. find below link to download the updated jdk with new version. it help me to solve my problem.

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Preconscious answered 28/3, 2017 at 8:19 Comment(0)
M
0

I also had to update the version of Tomcat I was using from Tomcat 7 to Tomcat 8.

Merrile answered 8/1, 2019 at 10:0 Comment(0)
S
0

I had the same issue. Turned out I used some external jars (apache poi 4.1.2) which were compiled with 1.8. Solved it by changing Java Build Path JRE to 1.8.

Subtenant answered 31/7, 2020 at 1:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.