Exception Caused by: java.lang.UnsupportedClassVersionError

14,149

The classes mentioned in the exception were compiled on a Java 7 JDK (that's what version 51.0 means), and therefore can't run on a Java 6 JRE. Recompile those classes with Java 6 or, if it's a library, get a JAR that was compiled with Java 6.

Share:
14,149
Aubergine
Author by

Aubergine

Spring; Spring Boot; Java; Kotlin; Couchbase; Reactor; WebFlux

Updated on June 30, 2022

Comments

  • Aubergine
    Aubergine almost 2 years

    Of course happened after messing up with versions(wish for java 7), kinder-garden ended by not being able to run project on tomcat directly.

    Whenever I am deploying .war(start.bat) web application on tomcat 7 by putting war under webapps folder I get exception(I don't need explanation of what the exception is - I know, but rather how to fix it):

    Caused by: java.lang.UnsupportedClassVersionError: : Unsupported major.minor version 51.0 (some classes)

    Steps taken:

    1. I took a look at most of the resources available either on web or here.

    2. JAVA_HOME environmental set to: C:\Program Files\Java\jdk1.6.0_30

    3. PATH environmental set to: C:\Program Files\Java\jdk1.6.0_30

    4. Tomcat shows java version when doing the run:

    Using CATALINA_BASE: "C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.23"

    Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.23"

    Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.23\temp"

    Using JRE_HOME: "C:\Program Files\Java\jdk1.6.0_30"

    Using CLASSPATH: "C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.23\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.23\bin\tomcat-juli.jar"

    1. In Eclipse ANT C:\Program Files\Java\jdk1.6.0_30\lib\tools.jar

    2. In build path jdk1.6.0_30

    Else, whenever I use tomcat server from Eclipse everything works fine...

    Guys please help, I count on you I've literally done research on that, still nothing.

  • Aubergine
    Aubergine over 12 years
    Ok, stupid me. For some reason I thought it should do it automatically whenever I run the application.