Java: Unsupported major.minor version 52.0

This error basically means that you compiled your Java code with the version higher than that on the target machine you are trying to run it on.

 $ java -versionjava version "1.8.0_20-ea"


Java 1.8 == 8 == 52 (go figure why this confusion)

J2SE 8 = 52,
J2SE 7 = 51, 
J2SE 6.0 = 50, 
J2SE 5.0 = 49, 
JDK 1.4 = 48, 
JDK 1.3 = 47, 
JDK 1.2 = 46, 
JDK 1.1 = 45

Solution 1: update Java version on target machine (often impossible)
Solution 2: compile with lower Java version (skip on fancy language features e.g. lambdas) 

e.g. using Maven

   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <!-- target has java version "1.7.0_60", to be safe we use 1.6  -->
               <source>1.6</source>
               <target>1.6</target>
            </configuration>
         </plugin>


e.g. using Java Compiler

javac -target 1.6 HelloWorld.java



As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles