How to fix “unsupported class file major version 60” in IntelliJ?
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!
-
How are you running it in Intellij? Doesn't intellij print the exact command at the top of the terminal panel? It usually does. Take that and compare it to what you were running manually – Michael Apr 13 at 17:06
-
2Does stackoverflow.com/a/66879514/104891 help? – CrazyCoder Apr 13 at 17:12
-
1@CrazyCoder I was today years old when I learned that Gradle has its own JDK setting rather than respecting the one you set for the project. 😡 Thanks, I'd have never thought to look that up! – Mason Wheeler Apr 13 at 17:22
-
And you will be tomorrow years old, when you learn, that IntelliJ will sometimes just forget about this setting and switches from PROJECT_JDK to something, that is around. – cfrick Apr 13 at 17:25