Facing "Unsupported class file major version 65" for gradle version 8.6

I am trying to run a simple java gRPC applicaiton mentioned here. I am running into the error:

startup failed:
General error during conversion: Unsupported class file major version 65

Here is the output to my gradle version:

Gradle 8.6

Build time:   2024-02-02 16:47:16 UTC
Revision:     d55c486870a0dc6f6278f53d21381396d0741c6e

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.2 (Oracle Corporation 21.0.2+13-LTS-58)
OS:           Mac OS X 14.2.1 aarch64

I have tried installing gradle 8.4 and 8.5 as well but nothing works here. Also for some reason I see the .gradle cache creating a directory for 7.3.3 I don’t know why and I assume is the gradle version. How do I fix this? Any help would be highly appreciated.

What Gradle version you have installed is irrelevant.
Usually you do not even have any Gradle version installed.
If you run a build, then the four Gradle wrapper files that every Gradle build should contain defines which version of Gradle should beused to run the build as the build is designed for that version and known working with that version. And you should always use those wrapper files to run a build.