Solution for Tomcat bad version number in class file

Source: Internet
Author: User

a classmate met a problem a few days ago, today I tried to look at it.

project has no errors, the Tomcat startup times is wrong after the project is deployed to Tomcat:

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

I have encountered this problem before, due to the generation of Java-generated class files, at run time with the JRE and class file version of inconsistency caused.

1 If the Java program is normal:

You can modify the path and version of the JRE in MyEclipse. In Window->preferences, you can modify the JRE by opening the following location:


after the modification, it is best to recompile, select Project->clean ... option, and then select whether all items will be recompiled, or only the specified project will be recompiled, and then it should be no problem.

I did it at the beginning of the day, but it was an error, and after searching the internet, because it was a Web project, and the program was run on Tomcat, of course, we couldn't.

2 If the Web program

you will need to modify the JDK environment for the Tomcat runtime, as shown in the following figure:

This problem is solved by setting the JDK path to the same as the previous installed JRE. (although this is set to the JDK path, I think it's actually setting the path to the JRE, because the Java program needs the JRE when it runs, not the JDK.) When we install JDK, we usually have 2 JRE installed, one is the JRE inside the JDK, there is a and JDK peer JRE, I just checked the internet, the two JRE is not very different, you can also go to check, each time you can choose any JRE, but then configure the yell before the same. )

If you are not clear about the relationship between the JDK and the JRE, you can check it online.

In General, we may run into someone else's program that might encounter this problem.

just a little extension.

this project compiles without error, if we import other people's projects, there are many errors, that is the JDK version of the problem, you can modify here:



You can choose 1.3,1.4,5.0,6.0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.