This is a record of Gradle setup failures and successes that I wrote down when using Java for the first time. (2018.02)
Set Java as a prerequisite for Gradle operation.
C:\Users\user>set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_161\bin"
C:\Users\user>java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) Client VM (build 25.161-b12, mixed mode, sharing)
Download from the official website https://gradle.org/
Unzip to a suitable folder
Set the path of the folder where you unzipped Gradle
C:\Users\user>set PATH=%PATH%;C:\tmp\gradle-4.5.1\bin
C:\Users\user>gradle -v
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_161\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
C:\Users\user>set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_161"
C:\Users\user>gradle -v
------------------------------------------------------------
Gradle 4.5.1
------------------------------------------------------------
Build time: 2018-02-05 13:22:49 UTC
Revision: 37007e1c012001ff09973e0bd095139239ecd3b3
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_161 (Oracle Corporation 25.161-b12)
OS: Windows 7 6.1 x86