Error occurred during initialization of VM. Failed setting boot class path

I’m a beginner so I’m sorry if this is a stupid problem.
I tried to run gradlew genSource and got this error:
VirtualMachineError
I had to change the java version from 8 to 16 early and I’m still not sure if there is some path that need to be adjusted and this is related.
I’m using intellij IDEA.

What version of Gradle is your project using? Gradle does not support running in Java 16 until version 7+.

I’m using Gradle 7.0.2