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:34

None of these answers helped me, but I found a solution.
I had a webproject used in Wildfly 8.2, built with Maven, source and target was set to 1.8 on maven-compiler-plugin, as well as all Eclipse and Maven settings were set to Java 1.8. The problem was that Wildfly 8.2 cannot handle Java 1.8, so I had to set everything to 1.7 and it worked.

查看更多
心情的温度
3楼-- · 2018-12-31 01:36

You must run and compile your application with the same version of Java.

If you're using Eclipse you should do 2 things:

  1. 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.

  2. 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.

查看更多
姐姐魅力值爆表
4楼-- · 2018-12-31 01:37

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.

Enter image description here

查看更多
看淡一切
5楼-- · 2018-12-31 01:39

Unsupported major.minor version 52.0 comes when you are trying to run a class compiled using Java 1.8 compiler into a lower JRE version e.g. JRE 1.7 or JRE 1.6. Simplest way to fix this error is install the latest Java release i.e. Java 8 and run your program.

Read more: http://javarevisited.blogspot.com/2015/05/fixing-unsupported-majorminor-version.html#ixzz4AVD4Evgv

查看更多
孤独寂梦人
6楼-- · 2018-12-31 01:39

If you are using Eclipse, make sure your menu ProjectPropertiesJava build pathlibrariesJRE system library matches your project requirements (as shown in the image).

Enter image description here

查看更多
梦该遗忘
7楼-- · 2018-12-31 01:41

I solved my problem by removing old versions of JRE and installing JRE 8.

查看更多
登录 后发表回答