Search code examples
javatomcatservletsweb-applicationscompatibility

Is it possible to deploy a jdk 6 (or 7) war in a container instance running in jre 5 environment?


I would compile a company legacy java web project, currently compiled with jdk 5, with jdk 6, in order to upgrade version of some libraries in use, like Struts, Axis etc...

Since this application need to be deployed in a Tomcat 5.5 instance, running in jre 5 environment, shared with multiple other project, neither Tomcat nor jre version can be upgraded.

I wonder if is it possible, to deploy a war containing code compiled with a java version (version 6 or 7) newer than the jre (version 5) running the container?


Solution

  • Short Answer: No

    Long Answer: It may be possible to compile your code with '-target 1.5'. However in this case all code including any bundled dependencies also need to be compiled with '-target 1.5' defeating the whole purpose of upgrading the JDK. You also need to be careful not to use any API that was introduced in Java 6 (or 7), not in your code nor in bundled dependencies.

    In other words there is no point in trying to do this as any potential benefit can not be utilized anyway.