Windows CMD – Set JAVA_HOME Variable Using Command Prompt
This post shows you how to set JAVA_HOME
environment variable using Windows CMD (Command Prompt).
1. Open CMD as administrator
First, we need to open CMD as administrator like this.
2. Set JAVA_HOME variable
Then use the following command to set JAVA_HOME
variable.
setx JAVA_HOME "path/to/your/java/jdk" /M
For example, we set “C:\Program Files\Java\jdk1.8.0_92” to JAVA_HOME
.
3. Check JAVA_HOME variable
Now open another CMD and use echo %JAVA_HOME%
command to check whether we did it right or not.
We are done!