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

The smart way to fix that problem is to compile using the latest SDK and use the cross compilation options when compiling. To use the options completely correctly requires the rt.jar of a JRE (not JDK) of the target version.

Given the nature of that applet, it looks like it could be compiled for use with Java 1.1.

查看更多
大哥的爱人
3楼-- · 2018-12-31 01:31

Upgrade your Andorra version to JDK 1.8.

This is a version mismatch that your compiler is looking for Java version 8 and you have Java version 7.

You can run an app build in version 7 in version 8, but you can't do vice versa because when it comes to higher levels, versions are embedded with more features, enhancements rather than previous versions.

Download JDK version from this link

And set your JDK path for this

查看更多
唯独是你
4楼-- · 2018-12-31 01:31

I ran into this issue in Eclipse on Mac OS X v10.9 (Mavericks). I tried many answers on Stack Overflow ... finally, after a full day I *installed a fresh version of the Android SDK (and updated Eclipse, menu ProjectPropertiesAndroid to use the new path)*.

I had to get SDK updates, but only pulling down those updates I thought were necessary, avoiding APIs I were not working with (like Wear and TV) .. and that did the trick. Apparently, it seems I had corrupted my SDK somewhere along the way.

BTW .. I did see the error re-surface with one project in my workspace, but it seemed related to an import of appcompat-7, which I was not using. After rm-ing that project, so far haven't seen the issue resurface.

查看更多
柔情千种
5楼-- · 2018-12-31 01:32

It happens when you compile your projects on higher version of java(say jdk 1.8) and then run it on a lower version (say jdk 1.7).

If you have JRE-1.7 library in your project path then ,

1.Right click on project

2.Go to Properties

3.Select Project Facets

4.Find Java in rows and then choose version (say 1.7) if using JRE-1.7

5.Click Apply and run your project.

查看更多
十年一品温如言
6楼-- · 2018-12-31 01:32

I had Java 1.7 & 1.8 installed (with SBT 2.4 that requires Java 1.8). Even though my project was linked to Java 1.8, I had to change the JAVA_HOME environment variable to point 1.8. Finally, problem solved.

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

If your JDK version is right. Another reason that may cause this error is that your Android Studio is in a low version, but your Gradle version is too high. Upgrade your IDE to a newer version may help this.

查看更多
登录 后发表回答