欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

不支持的major.minor版本52.0 [重复]

程序员文章站 2024-03-14 21:34:17
...

本文翻译自:Unsupported major.minor version 52.0 [duplicate]

Pictures: 图片:

不支持的major.minor版本52.0 [重复]Command Prompt showing versions 命令提示符显示版本

不支持的major.minor版本52.0 [重复]Picture of error 错误图片

Hello.java 你好

import java.applet.Applet;
import java.awt.*;

public class Hello extends Applet {

    // Java applet to draw "Hello World"
    public void paint (Graphics page) {
        page.drawString ("Hello World!", 50, 50);
    }
}

Hello.html Hello.html

<HTML>
    <HEAD>
        <TITLE>HelloWorld Applet</TITLE>
    </HEAD>

    <BODY>
        <APPLET CODE="Hello.class" WIDTH=300 HEIGHT=150>
        </APPLET>
    </BODY>
</HTML>

Error 错误

Hello : Unsupported major.minor version 52.0

What may the problem be? 可能是什么问题?


#1楼

参考:https://stackoom.com/question/1WMWE/不支持的major-minor版本-重复


#2楼

The smart way to fix that problem is to compile using the latest SDK and use the cross compilation options when compiling. 解决此问题的明智方法是使用最新的SDK进行编译,并在编译时使用交叉编译选项 To use the options completely correctly requires the rt.jar of a JRE ( not JDK ) of the target version. 完全正确地使用这些选项需要目标版本的JRE( 不是JDK )的rt.jar

Given the nature of that applet, it looks like it could be compiled for use with Java 1.1. 鉴于该applet的性质,它看起来可以进行编译以与Java 1.1一起使用。


#3楼

I had the same problem... a JDK and plug-in version conflict. 我遇到了同样的问题... JDK和插件版本冲突。

I compiled using 1.8 ... the latest one, and that message started to appear. 我使用1.8 ...进行了编译,最新的版本开始出现。 So I've searched for the JRE 7 ( http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html )... and installed it... again... Now 1.8 and 1.7 in the same computer. 因此,我搜索了JRE 7( http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html )...并再次安装了它。现在1.8和1.7在同一台计算机上。

Using NetBeans, and compiling, and targeting to version 1.7, fixed my problem. 使用NetBeans进行编译,并以1.7版为目标,解决了我的问题。


#4楼

If you're using the NetBeans IDE, right click on the project and choose Properties and go to sources , and you can change the Source/Binary Format to a lower JDK version. 如果您使用的是NetBeans IDE,请右键单击该项目,然后选择“ 属性”并转到“ 源” ,然后可以将“源/二进制格式”更改为较低的JDK版本。

不支持的major.minor版本52.0 [重复]


#5楼

You will need to change your compiler compliance level back to 1.7 in your IDE. 您将需要在IDE中将编译器的符合性级别更改回1.7。

This can be done in the preferences settings of your IDE. 这可以在IDE的首选项设置中完成。 For example, in Eclipse go to menu WindowsPreferences , select Java, and expand it. 例如,在Eclipse中,转到菜单Windows首选项 ,选择Java,然后将其展开。 Then select Compiler and change the compliance level to 1.7. 然后选择编译器 ,并将合规级别更改为1.7。 I am sure this will work from there. 我确信这将从那里开始。


#6楼

This occurred to me when I installed a fresh Java 1.8, but left the old command line interpreter open. 当我安装了新的Java 1.8时,这发生在我身上,但是打开了旧的命令行解释器。

It had an old path and kept on executing the application with Java 1.7 whereas project was already built with Java 1.8. 它的路径很旧,并且继续使用Java 1.7执行应用程序,而项目已经使用Java 1.8构建。