User variables and System variables
User variables are valid only for the current user, and system variables are valid for all users. When you retrieve a command, the system variable is in front of the user variable. In other words, if two places contain the same command, the system variable is prioritized to indicate the command under the path.
Set path =%path%;D: \java is valid only for the current command-line window.
Modify Windows environment variables to take effect without restarting
After setting the environment variable in My computer's properties, click OK to view the environment variable in cmd through the path command, sometimes it is not in effect and will not appear in path. The reason is that
Workaround: To modify the PATH variable as an example, in the advanced settings, after the modification, into the win+r->cmd boot DOS command prompt, set path=c, and other commands to set the environment variables can be, close the DOS window, open the DOS window again, enter PATH, Look at the environment variables, and you can tell that the path value in the environment variable, properties-----, my computer, is already in effect.
Workaround: Modify the environment variables in the DOS window, just modify a copy of the system environment variables, and do not affect each other. However, modifications to the copy cause a refresh of the Windows environment variables, which is exactly what we want. It is further explained that when a program is started, the environment variable is copied to the environment where the program is located, and will not be changed by programs other than the program during the execution of the program. That is, if we start a CMD program, then the control Panel modifies the environment variable settings, the CMD has the environment variables will not be changed, at this time, restart a CMD program, the program's environment variables will be changed.
Conclusion: Modify the environment variables, if the application is affected, then only need to restart the program to take effect. If the system service is affected, you must restart your computer to reflect the changes to the environment variables in the system service.