Question

I try to compile a webtools project for Java5/Tomcat 5.5 in ubuntu (with manually installed eclipse 3.4). I set the installed jre to java-1.5.0-sun-1.5.0.18 and the compiler compliance level to 1.5. When I export this to a .war file, and try to deploy it in 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)
...

Anybody knows how to solve this?

Was it helpful?

Solution 2

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

OTHER TIPS

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

check that all your jars are compiled for java5.

If it works in Windows, it's probably due to a difference in environments rather than a bug present in the Linux versions of the JDKs. Check to see if you have multiple JVMs present in Linux (you almost certainly do, since Ubuntu probably comes with a non-Sun version) and be 110% sure that you're using the expected version to compile. Issuing

which javac

and

echo $JAVA_HOME; echo $JDK_HOME

from a command-line might help too, since all of these could feasibly be used to locate a JDK (as well as the settings you use in your compile command/tool).

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

A naive one: After changing project preferences and before exporting the WAR file on Ubuntu, did you try to force compile on your projects ( Project -> Clean... in Eclipse) ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top