Java 不支持的 Major.minor 版本 49.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1525960/
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
Unsupported major.minor version 49.0
提问by Gourav
I am getting the following exception whenever I login to my application ...
每当我登录到我的应用程序时,我都会收到以下异常...
javax.servlet.ServletException: com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl (Unsupported major.minor version 49.0)
javax.servlet.ServletException:com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl(不支持的major.minor 版本49.0)
What does this mean and how can I resolve the problem?
这是什么意思,我该如何解决这个问题?
回答by Brian Agnew
You have a mismatch between your JVM that you're using to run the .class, and the version of Java used to compile the .class. The JVM running it is an earlier version of the JVM used to compile that class.
用于运行 .class 的 JVM 与用于编译 .class 的 Java 版本不匹配。运行它的 JVM 是用于编译该类的 JVM 的早期版本。
As detailed here, you have a version 1.5 class that you're trying to run on an earlier JVM.
如此处所述,您有一个 1.5 版的类,您正尝试在较早的 JVM 上运行该类。
EDIT : WAS 5.1 uses JDK 1.4, it would appear.
编辑:WAS 5.1 使用 JDK 1.4,它会出现。
回答by Rich Seller
You have some code compiled with Java 5 features that you're trying to run on a 1.4 or earlier JVM. Check your JAVA_HOME variable is pointing at a 1.5 or later JDK.
您尝试在 1.4 或更早版本的 JVM 上运行一些使用 Java 5 功能编译的代码。检查您的 JAVA_HOME 变量是否指向 1.5 或更高版本的 JDK。
Update: In your comment you say you are using WAS 5.1. WAS 5.1 doesn't support Java 5, from memory you need to be on WAS 6.1 to use Java 5 (looking for reference...)
更新:在您的评论中,您说您使用的是 WAS 5.1。WAS 5.1 不支持 Java 5,从内存中你需要在 WAS 6.1 上使用 Java 5(寻找参考...)
回答by dz.
If you do build your classes with a higher version of the JDK for a minor version of JAVA use the -source and -target switches of the javac compiler. Some customers do need a minor version of Java, e.g. 1.4, while you're developing with 1.6. -source and -target are is remedy for this szenario. You might read the very good paperabout byte code vs. source code versioning issues from Alex Buckley.
如果您确实为次要版本的 JAVA 使用更高版本的 JDK 构建类,请使用 javac 编译器的 -source 和 -target 开关。当您使用 1.6 进行开发时,某些客户确实需要 Java 的次要版本,例如 1.4。-source 和 -target 是针对这种情况的补救措施。您可能会阅读Alex Buckley 关于字节码与源代码版本控制问题的非常好的论文。
But since TransformerFactoryImpl is a Sun internal class, check your JAVA_HOME for your container, ut this is container specific.
但由于 TransformerFactoryImpl 是 Sun 内部类,请检查您的容器的 JAVA_HOME,这是特定于容器的。
回答by OscarRyz
Your code was compiled with Java 1.5 and your trying to run it with Java 1.4 ( or lower )
您的代码是用 Java 1.5 编译的,并且您尝试用 Java 1.4(或更低版本)运行它
The solution is
解决办法是
a) Run it with Java1.5 ( perhaps using WAS 6+ )
b) Recompile it with Java 1.4
or
或者
c) Recompile it with Java.15 but specifying the -target flag ( javac -target 1.4 .... )
The point is, you are trying to run 1.5 bytecode in a 1.4 vm
关键是,您正在尝试在 1.4 vm 中运行 1.5 字节码
回答by false9striker
Use sudo update-alternatives --config java and set the version you may want to use.
使用 sudo update-alternatives --config java 并设置您可能想要使用的版本。
回答by Luthoz
This happens when you have compiled your code in a machine that uses a different JDK version to the one you end up running the code in. Make sure you use the same JDK version in these different boxes.
当您在使用与最终运行代码的 JDK 版本不同的机器上编译代码时,就会发生这种情况。确保在这些不同的框中使用相同的 JDK 版本。