First, check if JAVA_HOME is already set by start a CMD and issue:

set JAVA_HOME

If JAVA_HOME is not set, you will receive “Environment variable JAVA_HOME not defined”. Otherwise, the current setting will be shown.

To set/change JAVA_HOME in Windows:

  1. Launch “Control Panel”
  2. “System”
  3. “Advanced system settings”
  4. Switch to “Advanced” tab
  5. “Environment variables”
  6. Choose “System Variables” (for all users)
  7. To add a new environment variable “JAVA_HOME“:
    1. Choose “New”
    2. In “Variable Name”, enter “JAVA_HOME”.
    3. In “Variable Value”, click “Browse Directory…” and navigate to the JDK installed directory (e.g., “C:\Program Files\Java\jdk-13.0.1“).
    4. OK ⇒ OK ⇒ OK.
  8. To change the existing “JAVA_HOME” setting:
    1. Select “JAVA_HOME” ⇒ “Edit”
    2. In “Variable Value”, click “Browse Directory…” and navigate to the JDK installed directory (e.g., “C:\Program Files\Java\jdk-13.0.1“).
    3. OK ⇒ OK ⇒ OK.

You need to RE-START CMD for the new setting to take effect!

To verify the new setting, re-start CMD:

set JAVA_HOME
JAVA_NAME=C:\Program Files\Java\jdk-13.0.1

NB:Replace jdk-13.0.1 by your current version