Unsupported major.minor version 52.0 (unable to load class com.servlet.MailSenderServlet)

异常

java.lang.UnsupportedClassVersionError: ntci/ca/servlet/MailSenderServlet : Unsupported major.minor version 52.0 (unable to load class com.servlet.MailSenderServlet)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2498)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:860)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1302)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4734)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase StartChild.call(ContainerBase.java:1408)atorg.apache.catalina.core.ContainerBase StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

异常原因

因为该程序jdk和代码不兼容出现bug,就把默认的jdk1.8改成jdk1.7,于是错误就出现了。而且,设置中也出现了警告:
Unsupported major.minor version 52.0 (unable to load class com.servlet.MailSenderServlet)_第1张图片
图1 Property->Java Compiler

Unsupported major.minor version 52.0 (unable to load class com.servlet.MailSenderServlet)_第2张图片
图2 Windows->Preference->Install JREs

在eclipse中进行开发的时候,build path 中JDK进行类库的编译(就是我们使用的类在不在这个JDK中),java compiler compliance level是对这个项目语法的编译(就是我们项目中语法的正确与否),也可以把java compiler compliance level中配置的编译版本号的作用看作是你这个项目将来开发完毕之后,要放到服务器上运行,那个服务器上JDK的运行版本。

解决方案

build path和java compiler compliance level统一版本,图2中compiler compliance level由1.8改为1.7

你可能感兴趣的:(myException)