Basically, just specify the JAVA_HOME environment variable in the jdk folder, not the jre folder. To run groovy, you need the JDK, not the JRE, so just make sure you have the JDK installed, and then make sure the correct folder is installed for JAVA_HOME var.
Oh, and don't forget to start a new cmd window after changing JAVA_HOME var so that it takes effect.
source share