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?

0


a source to share


5 answers


Compiled it under windows and it works! Some bug somewhere ... there will be a time when this problem will be fixed.



0


a source


java.lang.UnsupportedClassVersionError: Invalid version number in .class file



check all your jars are compiled for java5.

+1


a source


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).

0


a source


There is a smaller JDK running in your tomcat than the one used to compile some of your classes. Recompile with compatible JDK or upgrade JRE for tomcat.

0


a source


Naive: After changing the project settings and before exporting the WAR file on Ubuntu, have you tried to force compile your projects (Project -> Clean ... in Eclipse)?

0


a source







All Articles