Reputation: 3557
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.
Upvotes: 2
Views: 3584
Reputation: 874
Go to System ->Advanced System Setting ->Environment Variables. In System Variables, Click on New and provide the Following:
Variable name as : JAVA_HOME
Variable Value as :E:/JdkInstallions/Jdk1.7 (as on my system)
This should resolve the problem you are getting.
Upvotes: 0
Reputation: 16359
To set environment variables in Windows, go to the System control panel (the quickest way is to right click Computer
in the Start Menu and select Properties
), and select Advanced system settings
, and then Environment Variables...
Upvotes: 0
Reputation: 533462
This is how the shell works in Windows, Mac OSX and UNIX and I suspect all operating systems.
Each prompt has it's own environment which is separate to any other process you have running. You can set a variable temporarily, but this is not saved to disk or preserved because you might set it in a script but you don't want it to affect the whole system.
If you want to change an environment variable in Windows you need to do Start
-> Right Click Computer
-> Properties
-> Advanced Setting
-> Environment Variables
-> Add Property
.
On Linux, you add your SET line to the ~/.bashrc
file
Upvotes: 2
Reputation: 1499780
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:
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:
Upvotes: 3