bash 安装 Apache Tomcat 时出现 Java 版本错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18416178/
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
Java Version Error while installing Apache Tomcat
提问by Hyman
I know this question was asked so many times but I never found an answer that relates to my question. I am trying to install Apache Tomcat server on my MacBook Pro. All answers were answered for Windows and Eclipse. I want to install and configure the server using Terminal. So the problem is happening at the last step of the installation. I am getting the below error while installing the server. I know this is a problem is about Java version at run time, but I can't fix it. Note: I have already updated my Java version to the latest one. Please help.
我知道这个问题被问了很多次,但我从未找到与我的问题相关的答案。我正在尝试在我的 MacBook Pro 上安装 Apache Tomcat 服务器。Windows 和 Eclipse 的所有答案都得到了回答。我想使用终端安装和配置服务器。所以问题发生在安装的最后一步。安装服务器时出现以下错误。我知道这是一个关于运行时 Java 版本的问题,但我无法修复它。注意:我已经将我的 Java 版本更新为最新版本。请帮忙。
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : 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) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access
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)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) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access##代码##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)
线程“main”中的异常 java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 51.0
##代码##
回答by Jon Skeet
You say you've got the latest version, but then you also say you're using Java 1.6_051. That is notthe latest version of Java.
你说你有最新版本,但你又说你使用的是 Java 1.6_051。那不是最新版本的Java。
You need Java 7 - see this pagefor how to install Java 7 on Mac OSX.
您需要 Java 7 - 请参阅此页面了解如何在 Mac OSX 上安装 Java 7。
If you can't install Java 7 on your machine for some reason, you'll need to use a different version of Tomcat. Tomcat 8 requiresJava 7, as shown on the "which version" Tomcat page. You might also wish to consider using an older version of Tomcat anyway, given that Tomcat 8.0 is still only at RC-1 level - I would typically stick with a stable version unless you're willing to take on the pain of pre-releases.
如果由于某种原因无法在计算机上安装 Java 7,则需要使用不同版本的 Tomcat。Tomcat 8需要Java 7,如“哪个版本”Tomcat 页面所示。无论如何,您可能还希望考虑使用旧版本的 Tomcat,因为 Tomcat 8.0 仍仅处于 RC-1 级别 - 我通常会坚持使用稳定版本,除非您愿意承担预发布的痛苦。
回答by Prabhakaran Ramaswamy
For Tomcat 8 Any installed Java 7 or later JRE (32-bit or 64-bit) may be used.
对于 Tomcat 8 可以使用任何已安装的 Java 7 或更高版本的 JRE(32 位或 64 位)。
Please read the requirements
请阅读要求