Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception Caused by: java.lang.UnsupportedClassVersionError [duplicate]

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.

like image 640
Aubergine Avatar asked Aug 01 '26 16:08

Aubergine


1 Answers

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.

like image 161
Michael Borgwardt Avatar answered Aug 04 '26 06:08

Michael Borgwardt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!