tags:

views:

1172

answers:

4

This is a real noob question.

When I set up JAVA_HOME using the command line interface I used set JAVA_HOME = C:\Program Files\Java\jdk1.6.0_13

However when I open the JAVA_HOME variable from System>Advanced>Environment Variables the change is not visible. Are these two different settings?

I have this question every time I set up a new Jdk and have never fully understood why the two seem to be different.

+5  A: 

The variable you set on command line is for that command shell and any other processes it starts. When you set it from System/Advanced/Environment Variables it affects any other process you start, including command shell, after setting it. Depending on where you set it, it will be available to the same user or any other use who logs in as well.

Hemal Pandya
It only affects new processes started by Explorer (which is where the env change occurred). Anything already running that launches new processes (Launchy, etc) will launch them with the old environment.
Herms
@herms.+1. you are correct. as a matter of fact, any process started from that command shell would also not get the new value.
Hemal Pandya
+2  A: 

The JAVA_HOME you set by command line is set only for that session of the shell.

Bhushan
+2  A: 

Changes made to a parent process only propagate to newly-created children; try opening a new command prompt and inspecting the value there.

Ignacio Vazquez-Abrams
+1  A: 

What the others said... :-)

I will add that even after setting the variable in the dialog, processes already running are (in general) not aware of the change: eg. a command prompt window will still display the old value. You have to start another window to see the change.
In some (rare) cases, you might even need to log out and log back to validate the change (I saw that recently again).

PhiLho