Firstly: Download and Install Java

Please go to following link https://www.java.com/en/download/manual.jsp , download the java installation file and run it.

Secondly: Set the JAVA_HOME Variable

To set the JRE_HOME or JAVA_HOME variable:

  1. Locate your Java installation directory

    If you didn’t change the path during installation, it’ll be something like C:\Program Files\Java\jdk1.8.0_65

    You can also type where java at the command prompt.

  2. Do one of the following:
    Windows 7 – Right click My Computer and select Properties > Advanced
    Windows 8 – Go to Control Panel > System > Advanced System Settings
    Windows 10 – Search for Environment Variables then select Edit the system environment variables
  3. Click the Environment Variables button.
  4. Under System Variables, click New.
  5. In the Variable Name field, enter either:
    • JAVA_HOME if you installed the JDK (Java Development Kit)
      or
    • JRE_HOME if you installed the JRE (Java Runtime Environment)
  6. In the Variable Value field, enter your JDK or JRE installation path from step 1 .
  7. Restart your computer

Test your java

run following command in cmd terminal:

java -version

If java is successfully installed, the terminal should show something as following(actual version number might be different as per your installation time).

java version “1.8.0_202”