Code Review Videos > How I Fixed > How I ‘Fixed’: Unsupported class file major version 64

How I ‘Fixed’: Unsupported class file major version 64

OK, not a true fix today. Not in the sense that I’d like, anyway.

The gist of this is that I was trying to follow along with the JetBrains official Introduction to Coroutines and Channels tutorial. I cloned the GitHub repo, and opened in IntelliJ.

When the dependencies were downloaded via Gradle, I got the following error:

Unsupported class file major version 64Code language: JavaScript (javascript)

Which wasn’t that helpful.

On another tab I found a lot more info, mainly things like this:

Caused by: BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 64
	at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileScript(DefaultScriptCompilationHandler.java:139)
	at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileToDir(DefaultScriptCompilationHandler.java:95)
	at org.gradle.groovy.scripts.internal.BuildOperationBackedScriptCompilationHandler$2.run(BuildOperationBackedScriptCompilationHandler.java:54)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
	at org.gradle.groovy.scripts.internal.BuildOperationBackedScriptCompilationHandler.compileToDir(BuildOperationBackedScriptCompilationHandler.java:51)
	at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler$CompileToCrossBuildCacheAction.execute(FileCacheBackedScriptClassCompiler.java:190)
	at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler$CompileToCrossBuildCacheAction.execute(FileCacheBackedScriptClassCompiler.java:170)
	at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler$ProgressReportingInitializer.execute(FileCacheBackedScriptClassCompiler.java:211)
	at org.gradle.groovy.scripts.internal.FileCacheBackedScriptClassCompiler$ProgressReportingInitializer.execute(FileCacheBackedScriptClassCompiler.java:194)
	at org.gradle.cache.internal.DefaultPersistentDirectoryCache$Initializer.initialize(DefaultPersistentDirectoryCache.java:100)
	at org.gradle.cache.internal.FixedSharedModeCrossProcessCacheAccess$1.run(FixedSharedModeCrossProcessCacheAccess.java:86)
	at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.doWriteAction(DefaultFileLockManager.java:216)
	at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.writeFile(DefaultFileLockManager.java:206)
	at org.gradle.cache.internal.FixedSharedModeCrossProcessCacheAccess.open(FixedSharedModeCrossProcessCacheAccess.java:83)
	at org.gradle.cache.internal.DefaultCacheAccess.open(DefaultCacheAccess.java:139)
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:89)
	... 166 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 64
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:199)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:180)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:166)
	at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:287)
	at org.gradle.groovy.scripts.internal.GradleResolveVisitor.resolveFromResolver(GradleResolveVisitor.java:410)
	at org.gradle.groovy.scripts.internal.GradleResolveVisitor.resolve(GradleResolveVisitor.java:396)
	at org.gradle.groovy.scripts.internal.GradleResolveVisitor.visitClass(GradleResolveVisitor.java:1453)
	at org.gradle.groovy.scripts.internal.GradleResolveVisitor.startResolving(GradleResolveVisitor.java:241)
	... 189 moreCode language: HTML, XML (xml)

Which, whilst pretty wild, was helpful enough to point me at the word “gradle”, which as newb who has struggled with Java a lot lately, knew that meant something to do with the build system.

One thing that dawned on me was that I’d upgraded to Java version 20 over the weekend.

Could that be the cause?

Well, a quick look at the command line left me a little perplexed:

java 20 missing gradle

Does Gradle need to be installed on top of a new Java version?

I’m not sure.

Fortunately SDK Man can solve this:

sdk install gradle

But that didn’t solve the issue in IntelliJ.

The Solution

What worked for me was downgrading to Java 19.

That’s why I put the fixed part of the post title in inverted commas. I don’t consider this a true fix. To me, going forward a major version of a runtime shouldn’t break things that previously worked.

For clarity though, here’s exactly how I fixed it – for fellow Java / Kotlin newbs.

Using sdk manager I ran the command:

sdk list javaCode language: PHP (php)

This spits out a very large list, and to me, this wasn’t very intuitive the first few times I used it.

The sdk manager manages more than just Java. For example, earlier on I used it to sdk install gradle.

When you list out all the Java versions, you get something like this:

sdk man list java

What you need is the ‘thing’ you are installing (Java), and the specific version – or identifier. That’s the one on the right hand column.

I therefore ran:

sdk install java 19.0.2-openCode language: CSS (css)

Which gives:

sdk install java 19.0.2-open

I even include my screw ups in the screenshots 🙂

OK, once Java 19 is on, re-open the project.

You now need to switch from Java 20 to Java 19:

set java version in intellij idea

Then download all the correct stuff for that version of Java, for this specific project.

To do that, open the Gradle tab:

intellij idea gradle tab

And then reload the Gradle project. Note, this may make your fans spin:

intellij idea reload gradle project

From there, you should be able to load your project.

Fun times this Java lark.

4 thoughts on “How I ‘Fixed’: Unsupported class file major version 64”

  1. thank you this method definitely works I just this to make Spring Boot 3.0.6 work on Java 17

    Reply
  2. what is ‘sdk’ is that ./cmdline-tools/bin/sdkmanager if yes, that doesn’t have a “list” command it has “–list” but then it doesn’t have any java versions. I usually have to install java separately. (I am on MacOS)

    Reply
    • Is sdkmanager for Android?

      I’m not sure – I think there is confusion here.

      I’m using https://sdkman.io/

      sdk man has a command sdk list

      I have no experience with Android so am not sure what the problem might be.

      Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.