不支持的 Major.minor 版本 52.0 [英] Unsupported major.minor version 52.0

查看:51
本文介绍了不支持的 Major.minor 版本 52.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片:

显示版本的命令提示符

错误图片

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 版本不匹配.参考 JVM 规范,以下是用于不同 Java 版本的类文件的主要版本.(截至目前,所有版本都支持所有以前的版本.)

The issue is because of Java version mismatch. Referring to the JVM specification the following are the major versions of classfiles for use with different versions of Java. (As of now, all versions support all previous versions.)

<头>
Java SE 版本主要版本
1.0.245
1.145(不是错别字,相同版本)
1.246
1.347
1.448
5.049
650
751
852
953
1054
1155
1256
1357
1458
1559
1660

这些是分配的主要编号.有关不受支持的major.minor 版本的错误是因为在编译期间您使用了较高的JDK,而在运行时使用了较低的JDK.

These are the assigned major numbers. The error regarding the unsupported major.minor version is because during compile time you are using a higher JDK and a lower JDK during runtime.

因此,major.minor version 52.0"错误可能是因为 jar 是在 JDK 1.8 中编译的,但您尝试使用 JDK 1.7 环境运行它.报告的号码是必需号码,而不是您使用的号码.要解决这个问题,最好让 JDK 和 JRE 指向同一版本.

Thus, the 'major.minor version 52.0' error is possibly because the jar was compiled in JDK 1.8, but you are trying to run it using a JDK 1.7 environment. The reported number is the required number, not the number you are using. To solve this, it's always better to have the JDK and JRE pointed to the same version.

在 IntelliJ IDEA 中,

In IntelliJ IDEA,

  1. 转到Maven 设置Maven导入.将导入器的 JDK 设置为 1.8.
  2. 转到Maven SettingsMavenRunner.将 JRE 设置为 1.8.
  3. 转到菜单文件* → 项目结构SDKs.确保 JDK 主路径设置为 1.8.
  1. Go to Maven SettingsMavenImporting. Set the JDK for importer to 1.8.
  2. Go to Maven SettingsMavenRunner. Set the JRE to 1.8.
  3. Go to menu File* → Project StructureSDKs. Make sure the JDK home path is set to 1.8.

重启 IntelliJ IDEA.

Restart IntelliJ IDEA.

另一种可能有帮助的方法是指示 IntelliJ IDEA 使用哪个 JDK 版本启动.

Another approach which might help is by instructing IntelliJ IDEA which JDK version to start up with.

转到:/Applications/IntelliJ\IDEA\15\CE.app/Contents/Info.plist并将 JVM 版本替换为:

Go to: /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/Info.plist and replace the JVM version with:

<key>JVMVersion</key>
<string>1.8*</string>

这篇关于不支持的 Major.minor 版本 52.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆