Issue
I am trying to change my java version because of compiler errors when running mvn install
via the windows command prompt.
I changed the JAVA_HOME variable and made sure that it is referenced in the PATH variable (##EDIT##: had been done like this %JAVA_HOME%\bin;%PATH%;
).
When I open the command prompt in the folder where my pom.exe is located (using the Windows 7 'Open command window here'
shortcut) and type java -version
the unchanged java version is displayed.
I made sure to close all instances of command prompts before starting a new one.
Strangely I discovered that when starting the command prompt via the Run dialog
in the start menu
(by typing cmd
) the result of java -version
is the desired version.
Solution
When using the 'Open command window here'
shortcut make sure to close and open the respective explorer window. When starting the command prompt in this way Windows uses cached environment variables and does therefore not retrieve the current version of java.
Took me a while to figure out because it was too surprising to expect this behavior. Before I was searching on google and stackoverflow.com without any results. Hope this saves someone the trouble.
Answered By - Dennis
Answer Checked By - Marilyn (JavaFixing Volunteer)