Unsupported major.minor version 52.0 [duplicate]

2018-12-31 00:48发布

This question already has an answer here:

Pictures:

Command Prompt showing versions Command Prompt showing versions

Picture of error 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

<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?

26条回答
残风、尘缘若梦
2楼-- · 2018-12-31 01:20

All you need to do to solve the problem is... to make sure your version of Java is the same for both compiling and running. No matter what tools or IDEs you are using.

查看更多
弹指情弦暗扣
3楼-- · 2018-12-31 01:20

You may want to check your Run Configurations setting if you're using Eclipse v4.4 (Luna) and have already completed all steps mentioned above.

There could be several possibilities that cause this error. The root cause is a mismatch of the project require compilation in JDK1.8/JRE8 while the environment compiler is JDK1.7/JRE7.

You can check my blog post to go through all your settings are correct.

查看更多
不流泪的眼
4楼-- · 2018-12-31 01:20

If you are using IntelliJ IDEA, go to Project Structure (Ctrl + Alt + Shift + S), and you can change your project's JDK.

查看更多
萌妹纸的霸气范
5楼-- · 2018-12-31 01:21

Just want to add this. I had this problem today. Adjusted the settings in my project, rebuilt, and same problem. I had (incorrectly) assumed that changing the settings in my project (Eclipse) would cause the projects on which my project depends to be recompiled also. Adjusting the settings to all of the projects up the dependency tree solved the problem.

查看更多
君临天下
6楼-- · 2018-12-31 01:22

This occurred to me when I installed a fresh Java 1.8, but left the old command line interpreter open.

It had an old path and kept on executing the application with Java 1.7 whereas project was already built with Java 1.8.

查看更多
回忆,回不去的记忆
7楼-- · 2018-12-31 01:24

If you have a problem in Android Studio and you have installed Android N, change the Android rendering version with an older one and the problem will disappear.

Enter image description here

查看更多
登录 后发表回答