When JAVA_HOME
is not set, then echo
command will display the command instructions as it is:
C:\>echo %JAVA_HOME%
%JAVA_HOME%
To set the user environment variables, used setx
command to do it.
setx JAVA_HOME "C:\jdk-8u172"
SUCCESS: Specified value was saved.
C:\>echo %JAVA_HOME%
%JAVA_HOME%
How to display the user environment variable details on the command line?
But when the JAVA_HOME is added with set
command, then echo
command displayed the path added in JAVA_HOME
variable:
C:\>set JAVA_HOME="C:\jdk-8u172"
C:\>echo %JAVA_HOME%
"C:\jdk-8u172"
C:\Users\raju>
How echo
command is restricted to display user environement variable details?
from superuser post
It means...
set
command, then its used for the current shell session onlysetx
command, then its persistent, but to take effect, you need to open new shell otherwise it will be looking like its still not set- reopening new session will reload variables.