I'm switching between different Java SDKs (1.4.2, 1.5.0 and 1.6.0) for various projects. I would like to set the JAVA_HOME environment variable on my Windows XP machine without going through the tedious My Computer -> Advanced -> [Select System Variable] -> Edit -> Ok -> Ok
Is it possible to do this from the command line, or is there a utility that can do this?
(Note that I am not referring to the standard batch file "SET" command - I want to set the environment variable "globally," not just for the life of a console window).
On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.
2.2 Set/Unset/Change an Environment Variable for the "Current" CMD Session. To set (or change) a environment variable, use command " set varname=value ". There shall be no spaces before and after the '=' sign. To unset an environment variable, use " set varname= ", i.e., set it to an empty string.
Control Panel -> User Accounts -> User Accounts -> Change my environment variables (left side). This will open the user variables without admin access allowing the user's variables to be edited. Make sure the user account's name is showing where the red circle is. Save this answer.
From http://vlaurie.com/computers2/Articles/environment.htm:
Using the add-on tool Setx.exe
It is not part of the standard Windows XP setup but a command-line tool called setx.exe is included in the Windows XP Service Pack 2 Support Tools. This tool extends the set command so that permanent changes in the environment variables can be made. For example, to add a folder C:\New Folder to the path, the command would be setx path "%PATH%;C:\New Folder"
Service Pack 2 Support Tools has a tool called "setx.exe" that can do what you are looking for. setx path "%PATH%;C:\New Folder"
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With