如何修复“不受支持的类文件主要版本 60"在 IntelliJ 中? [英] How to fix "unsupported class file major version 60" in IntelliJ?

查看:54
本文介绍了如何修复“不受支持的类文件主要版本 60"在 IntelliJ 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 中有一个 Gradle 项目.它是用 Java 14 编写的.我安装了 Java 14 JDK.当我从命令行构建它时,一切正常,但没有人想使用命令行!当我在 IntelliJ Idea 中打开它时,它抛出一个错误:

* 其中:初始化脚本'/tmp/ijmapper.gradle`* 什么地方出了错:无法编译初始化脚本/tmp/ijmapper.gradle".>启动失败:语义分析期间的一般错误:不支持的类文件主要版本 60.

接着是一段很长的、无用的堆栈跟踪,里面说了很多关于 Groovy 的信息.(该项目不是 Groovy 项目;而是 Java 项目.)

参见 https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jvm_settings

I have a Gradle project in Ubuntu. It's written in Java 14. I have the Java 14 JDK installed. When I build it from the command line, everything works, but no one wants to use a command line! When I open it in IntelliJ Idea, it throws an error:

* Where:
Initialization script '/tmp/ijmapper.gradle`

* What went wrong:
Could not compile initialization script '/tmp/ijmapper.gradle`.
> Startup failed:
General error during semantic analysis: Unsupported class file major version 60.

followed by a long, unhelpful stack trace that says a lot about Groovy. (The project is not a Groovy project; it's a Java project.)

Major version 60 refers to Java 16, which this project is not using. I've already gone into Project Structure and made sure that it's set to use JDK version 14. But the name "ijmapper" suggests that this has something to do with IntelliJ specifically, and this is likely an IDE problem rather than a project problem.

The mapper file simply says:

if(!ext.has('mapPath')) ext.mapPath = { path -> path}

A simple polyfill, in other words.

Does anyone have any idea what's going on here and how to fix it? I've lost a day already trying to get this to work and I'm about at my wits' end here!

解决方案

I fixed this problem by changing the Gradle JVM settings in IntelliJ settings:

  • In the Settings/Preferences dialog, go to Build, Execution, Deployment | Build Tools | Gradle.

  • Under the Gradle section, change the Gradle JVM option. Select a Gradle JVM which works for you.

See https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jvm_settings

这篇关于如何修复“不受支持的类文件主要版本 60"在 IntelliJ 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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