Reputation: 148
I have set my environment variables up. JAVA_HOME has a value of: C:\Program Files\Java\jdk1.6.0_45 My path has this inside it as one of the values: $JAVA_HOME\bin
so when i type in java -version to the command line. does it return this: Error: could not open 'C:\Program Files\Java\jre1.8.0_20\lib\amd64\jvm.cfg'
surely I am pointing at the new 1.6 version? why is it being like this?
$JAVA_HOME\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\TortoiseSVN\bin;%M2_HOME%\bin;
Upvotes: 4
Views: 11752
Reputation: 12527
Make sure that %JAVA_HOME%\bin is the very first entry in you path.
The PATH is an ordered list of directories to search for a command. The search stops after the first match. So it sounds like there is a Java 1.8 entry before your $JAVA_HOME\bin entry.
One more possibility - if you are doing this from a command prompt - be sure to open a new command prompt after setting an environment variable. Changes to environment variables are not automatically applied to existing command prompt sessions.
Upvotes: 16