How to compile .war for Java 5 / Tomcat 5.5 on Ubuntu?
I am trying to compile a webtools project for Java5 / Tomcat 5.5 in ubuntu (with eclipse 3.4 manually installed). I have set the installed jre to java-1.5.0-sun-1.5.0.18 and the compiler compliance level is 1.5. When I export this to a .war file and try to deploy it to Tomcat (Windows XP, Tomcat 5.5.27, Java 1.5.0_18), I get the following error:
SEVERE: Error deploying web application archive Jdbc2Ei.war
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1 (Native Method)
at java.lang.ClassLoader.defineClass (Unknown Source)
...
Does anyone know how to solve this?
a source to share
If it works on Windows, it is probably due to a difference in environments, not a bug present in the Linux JDK versions. Check if you have multiple JVMs present on Linux (you almost certainly do, since Ubuntu probably ships with a non-Sun version) and is 110% sure that you are compiling the expected version. Issue
which javac
and
echo $JAVA_HOME; echo $JDK_HOME
from the command line can help too, as they can all be used to find the JDK (as well as the options you use in your compilation command / tool).
a source to share