The set
command only works for the current terminal. To permanently set a system or user environment variable you can use setx
.
You can set the variable for the current user like this:
setx JAVA_HOME "C:\Program Files\Java\jdk1.7.0_72"
You can also set the variable system wide (Note: The terminal must be run as administrator fo this) by running the same command with the /m
option:
setx JAVA_HOME "C:\Program Files\Java\jdk1.7.0_72" /m
The variable will be available in all new terminal session, but not the current one. If you also want to use the path in the same sessoin, you need to use both set
and setx
.
You can avoid manipulating the PATH
variable if you just once put %JAVA_HOME%
in there, instead of the full JDK path. If you change JAVA_HOME
, PATH
will be updated too.
There are also a few environment variable editors as alternative to the cumbersome Windows environment variable settings. See “Is there a convenient way to edit PATH in Windows 7?” on Super User.