[Common errors and solutions for JDK version] Unsupported major.minor version 51.0,

Hello, how are you, I am the little gray ape! A programmer who can write bugs!

Today we will not write bugs, we will solve bugs.

With so many bugs written, someone is always needed to solve it, isn’t it? ! !

Later, I will continue to update the various intractable diseases encountered in java development in this column to help my friends solve bugs faster!

Today, when I used junit for unit testing, I ran the test code, and there was an error like this:

Unsupported major.minor version 51.0

The translation is: Professional version 51.0 is not supported

(Bad English) It probably means that the version of a certain thing you use is wrong, which causes the system to not support it!

I was very confused at the time, and then I searched for related solutions on Baidu, and there were quite a few solutions to this bug. However, many of them are inadequate, and a lot of long talks have yet to solve the problems.

Later, after careful study and summary, it was found that the cause of this bug was because the JDK version of your project project was different from the JDK version that came with your computer. The error I reported above is 51, which corresponds to the jdk1.7 version, which means that my computer does not support the jdk1.7 version used in my current project.

The following is the jdk version corresponding to the response number:
  • J2SE 8 = 52,
  • J2SE 7 (jdk1.7) = 51,
  • J2SE 6.0 (jdk1.6) = 50,
  • J2SE 5.0 (jdk1.5) = 49,
  • JDK 1.4 = 48,
  • JDK 1.3 = 47,
  • JDK 1.2 = 46,
  • JDK 1.1 = 45

What to do then?

Easy to handle, just change the jdk version of the project project.

Here are the steps :

1. Right-click your project and select the bottom Preference, and then find in the pop-up dialog box: java compiler,

2. After finding the Compiler Compilance level, there is the version number of jdk,

I just opened it here, because the error parameter I reported is 51, which corresponds to the jdk1.7 version, so you can see the yellow error reminder below.

3. Now I lowered the version number to 1.6, the error reminder is gone, indicating that it's all right now!

4. After clicking OK, a prompt box will appear, click yes,

Now run the code again, the problem can basically be solved!

If you have a problem or can’t solve it, or have other solutions, please leave a message in the comment area!

I am the little gray ape! See you next time!