Path variable not staying set

I'm working on setting up my development environment in Windows 7, installing Maven, etc. I've been running into path issues and have read, ad nauseum, other posts that pointed me in the right direction. My problem is, however, that my PATH variable (JAVA_HOME) isn't staying set.

When I try

mvn --version

I get

Error: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the location
of your Java installation.

So, I set it

set JAVA_HOME=C:\Tools\Java

and then mvn --version works. But if I close and then reopen the Windows terminal I just end up getting the original error. Super frustrating.

I've also added that path to the Environmental Variables in the Systems Settings (with the semi-colon spacing, etc) Path section.

Jon Skeet
people
quotationmark

You're only setting it within that shell. This is perfectly normal behaviour for environment variables - not just on Windows, but on other OSes too.

I don't know about Windows 7, but on Windows 8 if I press the Windows key and start typing "Environment Variables" I get an option to open the control panel applet for editing the user or system environment variables. That's where you want to put it. The right dialog looks like this:

Environment Variables dialog

If the method above doesn't get to it, you can use the System Properties dialog, which has a button near the bottom for it:

System properties dialog

people

See more on this question at Stackoverflow