Unsupported major.minor version 51.0 error after m

2019-02-19 05:22发布

I am getting a Unsupported major.minor version 51.0 error after moving from IntelliJ IDEA JBoss to MyEclipse Tomcat.

Everything was working great under IntelliJ IDEA and JBoss and now we are moving to MyEclipse and Tomcat 6..

I am getting:

Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141

can someone please tell me how to fix this issue

2条回答
Anthone
2楼-- · 2019-02-19 05:45

It seems that the version of JRE under tomcat is newer than the one used to compile the code.

To fix the actual problem you should try to either update your JRE pointing in Tomcat with newer version Java JRE or specify target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions in Eclipse.

查看更多
手持菜刀,她持情操
3楼-- · 2019-02-19 05:53

This happens when you compile the code in a higher version of the JDK than you are using at runtime.

You can set the compiler version here:

Project -> Properties -> Java Compiler
查看更多
登录 后发表回答