java.lang.UnsupportedClassVersionError: myApp : Unsupported major.minor version 51.0 (unable to load class myApp) 在 Linux 上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12331138/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:27:40  来源:igfitidea点击:

java.lang.UnsupportedClassVersionError: myApp : Unsupported major.minor version 51.0 (unable to load class myApp) On Linux

javalinuxtomcat

提问by Deepu

Recently I am the facing problem with Apache Tomcat 6.0.35 on Linux Centos. I am getting the error -

最近我在 Linux Centos 上遇到了 Apache Tomcat 6.0.35 的问题。我收到错误 -

java.lang.UnsupportedClassVersionError: myApp : Unsupported major.minor version 51.0 (unable to load class myApp)

When I give the command -

当我发出命令时——

java -version

It Shows

表明

java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.9) (rhel-1.28.1.10.9.el5_8-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)

Similarly When I give the command -

同样,当我发出命令时 -

javac -version

It shows -

表明 -

javac 1.6.0_22

To locate the Java I give the command -

要定位 Java,我给出了命令 -

whereis java

The output is -

输出是 -

java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz

And for

而对于

which java

It displays -

它显示——

/usr/bin/java

Also for

也为

which javac

Output is

输出是

/usr/bin/javac

Where myAppis java project developed in Windows and Uploaded the WAR file in Tomcats' webappdirectory on Linux.

其中myApp是在 Windows 中开发的 java 项目,并在Linux上的Tomcats 的webapp目录中上传了 WAR 文件。

I am not getting what is happening? Please can anybody please help me to resolve the problem?

我不明白发生了什么?请问有人可以帮我解决问题吗?

Thanks in advance.

提前致谢。

采纳答案by ziesemer

You need a Java 7 runtime, not Java 6. See http://en.wikipedia.org/wiki/Java_class_file#General_layoutfor some details concerning this.

您需要 Java 7 运行时,而不是 Java 6。有关这方面的一些详细信息,请参阅http://en.wikipedia.org/wiki/Java_class_file#General_layout

Alternatively, you need to find and/or re-compile your code to be compatible with Java 6.

或者,您需要查找和/或重新编译您的代码以与 Java 6 兼容。

回答by basiljames

The exception is because yor code is compiled using a higher version than the one you are trying to run it on. In your windows machine you might be using windows 7 to build the war. Check javac -versionin your windows machine.

例外是因为您的代码是使用比您尝试运行的版本更高的版本编译的。在您的 Windows 机器上,您可能正在使用 Windows 7 来构建War。检查javac -version您的 Windows 机器。

回答by Peter Svensson

Looks like your code is compiled with jdk7?

看起来你的代码是用jdk7编译的?