2

I have created a Restful Webservice(compiled and run on Java 8) with Tomcat Server on Windows machine. I have deployed it on Ubuntu System and it is working fine now until I set Java_Home path of Ubuntu system as JDK 8. After going through below link servlet init exception running jersey servlet on tomcat 7

But when my the path was JDK 7 or version below JDK 8 the war used to throw below exception :

type Exception report

message Servlet.init() for servlet Jersey Web Application threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception javax.servlet.ServletException: Servlet.init() for servlet Jersey Web Application threw exception

root cause java.lang.UnsupportedClassVersionError: com/cms/RegisterVehicle/Registration/VehicleResource : Unsupported major.minor version 52.0

I want to know why War complied on JDK 8 is not compatible with the Server of JDK 7 ?

Janhavi Gadkari
  • 123
  • 2
  • 13

1 Answers1

1

This is because the Java runtime is written to only run code that was compiled to a version equal or earlier then their own. This is because older VMs won't know about new features of the language or may not understand any new bytecode introduced in the new version.

To fix your problem you will need to either compile your code using Java 7 or upgrade the version of the VM that is used to run Tomcat.

Chris Baldwin
  • 539
  • 3
  • 9