4

I have codes compiled on JDK 1.8. I created war file and deployed it on Tomcat8 in an Ubuntu server running JRE 1.8. I have this error when opening the main page:

java.lang.UnsupportedClassVersionError: com/dash/io/web/bind/HomeCtrl : Unsupported major.minor version 52.0

$ java -versionjava version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

$ javac -version
javac 1.8.0_45

$ echo $JRE_HOME
/usr/local/java/jdk1.8.0_45/jre

$ /usr/local/apache-tomcat-8.0.22/bin/catalina.sh version 
Using CATALINA_BASE:   /usr/local/apache-tomcat-8.0.22 
Using CATALINA_HOME:  /usr/local/apache-tomcat-8.0.22 
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.0.22/temp 
Using JRE_HOME:        /usr/local/java/jdk1.8.0_45/jre 
Using CLASSPATH:       /usr/local/apache-tomcat-8.0.22/bin/bootstrap.jar:/usr/local/apache-tomcat-8.0.22/bin/tomcat-juli.jar 
Server version: Apache Tomcat/8.0.22 
Server built:   Apr 29 2015 11:46:15 UTC 
Server number:  8.0.22.0 
OS Name:        Linux 
OS Version:     3.13.0-52-generic 
Architecture:   amd64 
JVM Version:   1.8.0_45-b14 
JVM Vendor:     Oracle Corporation

Need help. Thanks.

Mark Lauda Lauw
  • 261
  • 2
  • 10
  • I have the idea this question is closed as a duplicate for all the wrong reasons. You are not asking about what the error means but about why you get it even though you are using a Java 8 runtime, right? – Gimby Jun 10 '15 at 14:22
  • Yes, you are correct Gimby. Normally this error occurs when the codes are compiled using JDK1.8 and run using JRE 1.7. However in my case I have used JRE1.8. I couldn't find the solution for this case in other threads. Thanks. – Mark Lauda Lauw Jun 10 '15 at 14:31
  • Well its rather simple although it may be hard to accept: you're not running Tomcat through Java 8 if you get that error. Let me be precise: I think /usr/local/java/jdk1.8.0_45/jre is actually a Java 7 runtime through some black magic. Try running java -version directly in its bin directory to verify that. – Gimby Jun 11 '15 at 09:08

1 Answers1

0

I'm guessing you are using maven to make your war and the maven-compiler-plugin. Have you well set your source and target version there ? The default configuration may not be what you want. http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

Akah
  • 1,890
  • 20
  • 28
  • Hi Akah, I'm not using Maven. I'm using Gradle and I have put the following lines: sourceCompatibility = 1.8 targetCompatibility = 1.8 – Mark Lauda Lauw Jun 10 '15 at 14:33