Sounds like your Java version is not set properly. I assume you're on a unix machine. You can see which versions you have installed:
Mine (Mac) yields this:
Matching Java Virtual Machines (1):
11.0.7, x86_64: "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
Since I have "11.0.07" set, I set my
JAVA_HOME variable to:
export JAVA_HOME=`/usr/libexec/java_home -v 11.0.7`
That will work in your current command line session. You can add it to your
.zshrc (depending on your shell) to persist between command line sessions.
You can check the Java version you're currently using with
javac -version and if those are not working, Java isn't installed correctly. That should solve your issue with Gradle as it uses the Java compiler. But I found that version 13 does not work and I had to install version 11 to get it to compile correctly.
I came across this question while searching for something different and I got this working after a lot of trouble myself, so I figured I'd leave an answer here if anyone else stumbled across this question like I did.