Java hit jar package exception one: Could not find the main Class,java.lang.unsupportedclassversionerror:bad version numb

Source: Internet
Author: User

Java hit jar package exception one: Could not find the main Class,java.lang.unsupportedclassversionerror:bad version numb.

Reason: JDK version conflict problem

Reference articles:

Http://jn3.141592654.blog.163.com/blog/static/27477260201031285943166/?hasChannelAdminPriv=true

A section of code that works properly in JCreator, in MyEclipse

Always appear could not find the main class,program'll exit.

This is enough to explain that the code is correct, is the problem of the program.

The reasons and solutions are as follows:

Because we are using a high version of the JDK compiled Java class file to try to run on a lower version of the JVM, the reported error. Because the high version of the JDK generated class file uses a format that may be different from the. class file format of the lower version of JDK. In this way, the lower version of the JVM cannot interpret the execution of this. class file, throwing Couldnot find the main Class.program will exit unsupported class version error. This error was particularly evident in the previous version of JDK5 and JDK5. Because, JDK5 has made a lot of enhancements in Java syntax, introduced some elements of a new. class file, causing the old JVM to fail to interpret and execute the. class file. Even though this class does not use any JDK5 new elements, the. class file JDK5 generated by JDK1.4 and its previous JVM is unrecognizable.

Workaround:

1. Find out which JDK version the program was developed under (JDK should not be unfamiliar to Java learners)


2. In the MyEclipse menu->windows->proferences->java->installs jres Reset the JDK path to the JDK version of the development program (pictured above) (as shown above) (I can do this.) My eclipse is 7.0,jdk is 6u13. )

3.windows->proferences->java->compiler, set the compilercompliance level to the same JDK as above (pictured above, If you are 2011 to the official download of the JDK that may be 1.6, it is recommended to tick 1.6

-----------------------------------------------------------------------------

For the project, sometimes the version problem is also related to the compilation level, then it can be modified (see below)

Solve this

Method Two: change the package, the corresponding project of different versions of the replacement, such as My project is originally jdk1.5 version, now the jdk1.6 version of the tool,

Right-click the item name-—— > Properties to remove the 1.6 package.

(2) Add the jdk1.5 package and click Add Library.


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.