Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change environment variable (JAVA_HOME) without logging out

I'm currently developing in 3 different Java versions and therefore often change my JAVA_HOME variable. However, I have to log out in order to get the variable updated. I update it via System Properties -> Advanced -> Environment Variables (Windows XP).

Surely there is a smarter/easier way of doing this.

I guess I could use the SET command in prompt, but that is not permanent and as I often use one Java version for a period of time I don't want to reset it every time I start the PC.

Any suggestions?

like image 208
Linora Avatar asked Mar 11 '26 11:03

Linora


2 Answers

You don't have to log out to get an environment variable to stick, but you do have to restart whatever processes you're interested in. So for example, if you're using the command prompt, you will need to kill the command prompt and start a new one.

like image 117
Jon Skeet Avatar answered Mar 14 '26 01:03

Jon Skeet


You could create 3 .bat files, each setting the JAVA_HOME variable and then starting your Development Environment.

like image 28
Tim Meyer Avatar answered Mar 14 '26 03:03

Tim Meyer