Echo user environement variable details in commandline, viz JAVA_HOME, PATH

79 views Asked by At

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?

1

There are 1 answers

3
xxxvodnikxxx On

from superuser post

SETX is for user variables.

SET is for shell variables.

It means...

  • When you use set command, then its used for the current shell session only
  • When you use setx 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.