图片:

显示版本的命令提示符

错误图片

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

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

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

错误

Hello : Unsupported major.minor version 52.0

可能是什么问题?


当前回答

您必须使用相同版本的Java运行和编译应用程序。

如果你正在使用Eclipse,你应该做两件事:

In Eclipse, click on "Window > Preferences", and in the window that appears, on the left side, under "Java", click on "Installed JREs", click on "Add..." and navigate to the folder that contains the JDK. Right-click on your project and click on "Properties", in the window that appears, on the left side, click on "Java Compiler" and uncheck "Use compliance from execution environment on the Java Build Path", this allows you to choose in the the list "Compiler compilance level" the same version that you set in the previous step.

其他回答

如果你在Android Studio中遇到问题,并且你已经安装了Android N,将Android渲染版本更改为旧版本,问题就会消失。

当你在更高版本的java(比如jdk 1.8)上编译你的项目,然后在低版本的java(比如jdk 1.7)上运行时,就会发生这种情况。

如果你的项目路径中有JRE-1.7库,

1.右键单击项目

2.转到属性

3.选择项目方面

4.在行中找到Java,如果使用JRE-1.7,则选择version(例如1.7)

5.单击Apply并运行项目。

如果JDK版本正确。另一个可能导致这个错误的原因是你的Android Studio版本太低了,而你的Gradle版本太高了。将IDE升级到新版本可能会有所帮助。

您必须使用相同版本的Java运行和编译应用程序。

如果你正在使用Eclipse,你应该做两件事:

In Eclipse, click on "Window > Preferences", and in the window that appears, on the left side, under "Java", click on "Installed JREs", click on "Add..." and navigate to the folder that contains the JDK. Right-click on your project and click on "Properties", in the window that appears, on the left side, click on "Java Compiler" and uncheck "Use compliance from execution environment on the Java Build Path", this allows you to choose in the the list "Compiler compilance level" the same version that you set in the previous step.

这些答案对我都没有帮助,但我找到了一个解决方案。 我有一个在Wildfly 8.2中使用的webproject,用Maven构建,源和目标在Maven -compiler-plugin上设置为1.8,所有Eclipse和Maven设置都设置为Java 1.8。 问题是Wildfly 8.2不能处理Java 1.8,所以我必须将所有内容都设置为1.7,然后它就工作了。