0

When building my application I am receiving the error:

Unsupported major.minor version 51.0

After attempting to solve the problem myself using previous answers I am still unable to build the program. My understanding is that this error is caused due to incompatible compiler compliance and runtime environments.

Previous solutions have suggested to:

  • Upgrade your Java runtime or
  • Recompile the class if you have the source, using your local Java compiler (if you have one).

@Brad Parks - https://stackoverflow.com/users/26510/brad-parks

As I am not able to recompile the file producing the error I have attempted to upgrade my JRE from JSK1.6 to JDK1.8 - This now produces the error:

Unsupported major.minor version 52.0

I am still very new to Java so expect that I may have overlooked / misunderstood something

Community
  • 1
  • 1
Adam Hodgson
  • 325
  • 5
  • 12
  • You would probably need an inferior version than 1.8.. try with 1.6 – perencia Apr 14 '16 at 10:09
  • Have you changed your eclipse configuration? Perhaps eclipse is using other jdk than 1.8. This link is a little old, but can help to you: http://stackoverflow.com/questions/24790834/cant-fix-unsupported-major-minor-version-52-0-even-after-fixing-compatibility – Jose Luis Apr 14 '16 at 10:11
  • 2
    Whenever you get "Unsupported major minor..;" it means that you are trying to run your application in a lower version of Java compared to the one you compiled it in. Can you check what version you use to run and which one to compile? – Stultuske Apr 14 '16 at 10:12
  • It seems you upgraded or use a JDK version 1.7 now which complains about JDK8 generated class files. Please recheck the used java version with "java -version". Maybe check your Eclipse project settings if the message appears in Eclipse. A JDK8 environment does not complain about class 52 version files. – Konrad Apr 14 '16 at 10:23
  • @JoseLuis My Eclipse configuration is currently: JDK1.8 JRE8 – Adam Hodgson Apr 14 '16 at 10:36
  • You could check if your project has custom configuration. Perhaps it it using 1.6. – Jose Luis Apr 14 '16 at 10:41
  • And open a cmd windows (console) and write: echo JAVA_HOME. If the path that points to is not your jdk 1.8, you need to change it. – Jose Luis Apr 14 '16 at 10:44

1 Answers1

0

Check the version of your .class with javap -verbose MyClass and you would know which version that class was compiled for. As taken from Wikipedia:

Java SE 8 = 52 (0x34 hex)

Java SE 7 = 51 (0x33 hex)

Java SE 6.0 = 50 (0x32 hex)

Java SE 5.0 = 49 (0x31 hex)

JDK 1.4 = 48 (0x30 hex)

JDK 1.3 = 47 (0x2F hex)

JDK 1.2 = 46 (0x2E hex)

JDK 1.1 = 45 (0x2D hex)

perencia
  • 1,498
  • 3
  • 11
  • 19