java Tomcat 问题:不支持的 Major.minor 版本 52.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34365188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat Issue: Unsupported major.minor version 52.0
提问by 0xtimur
I am a newbie, so you might have to simplify explanation for me.
On my command line it says tomcat started.
But when I try to go to my browser and type 'Http://localhost:8080'
it says failed to open page.
我是新手,所以你可能需要为我简化解释。在我的命令行上,它说tomcat started。但是当我尝试转到我的浏览器并输入时,'Http://localhost:8080'
它说无法打开页面。
In the Tomcat log I got this error:
在 Tomcat 日志中,我收到此错误:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.accessNetBeans: No suitable Deployment Server is defined for the project or globally.
0(URLClassLoader.java:58)
at java.net.URLClassLoader.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
FYI
供参考
java version "1.8.0_60"
java版本“1.8.0_60”
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java(TM) SE 运行时环境(构建 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Java HotSpot(TM) 64 位服务器 VM(构建 25.60-b23,混合模式)
I have download the latest tomcat version. I am using NetBeans
我已经下载了最新的 tomcat 版本。我正在使用 NetBeans
I have two netbeans one was standard edition that I added the EE plugin (don't know if this has any relevance), the other netbean is download as the EE. Why because I don't know what I am doing and macdoesn't allow me to delete and I don't want to use the command line to this because again I don't know what I am doing.
我有两个 netbeans,一个是标准版,我添加了 EE 插件(不知道这是否有任何相关性),另一个 netbean 作为 EE 下载。为什么,因为我不知道我在做什么,而mac不允许我删除,我不想使用命令行,因为我不知道我在做什么。
I have been spending a lot of time on this and I am assuming it has something to do with either JAVA_HOME or the version of the JDK. If that is the case please I need instruction on how to do this. I have been trying to instal maven and tomcat for 2 days now.
我花了很多时间在这上面,我假设它与 JAVA_HOME 或 JDK 的版本有关。如果是这种情况,请我需要有关如何执行此操作的说明。我已经尝试安装 maven 和 tomcat 2 天了。
**This might help also when I try to run a project on netbeans it says:
**当我尝试在 netbeans 上运行一个项目时,这可能也有帮助,它说:
#!/bin/sh JAVA_HOME=/usr/local/apache-tomcat-9.0.0.M1/bin
Things I have don't but don't know why: Inside my catalina.sh I have written this:
我没有但不知道为什么的东西:在我的 catalina.sh 里面我写了这个:
timurs-MacBook-Air:~ timur$ export PATH=$JAVA_HOME/bin:$PATH
On my command line LASTLY I have written this:
最后在我的命令行上我写了这个:
timurs-MacBook-Air:~ timur$ /usr/local/apache-tomcat-9.0.0.M1/bin/catalina.sh version
Using CATALINA_BASE: /usr/local/apache-tomcat-9.0.0.M1
Using CATALINA_HOME: /usr/local/apache-tomcat-9.0.0.M1
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-9.0.0.M1/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /usr/local/apache-tomcat-
9.0.0.M1/bin/bootstrap.jar:/usr/local/apache
-tomcat-9.0.0.M1/bin/tomcat-juli.jar
This is tomcat Version info:
这是 tomcat 版本信息:
##代码##回答by Ritesh Karwa
java.lang.UnsupportedClassVersionError happens because of a higher
JDK during compile time and lower JDK during runtime.If you are using eclipse do the following go to menu command Window -> Preferences -> Java -> Compiler and then set "Compiler compliance level" to 1.8
- Make sure JRE_HOME is set to 1.8
java.lang.UnsupportedClassVersionError 发生的原因是
编译时 JDK较高,运行时 JDK 较低。如果您使用的是 eclipse,请执行以下操作,转到菜单命令 Window -> Preferences -> Java -> Compiler,然后将“Compiler compliance level”设置为 1.8
- 确保 JRE_HOME 设置为 1.8