4

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;

1 Answer 1

16

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.

Sign up to request clarification or add additional context in comments.

6 Comments

it seemed like the perfect solution. but it is still being annoying and not cooperating. i have added full path value to the question. am i doing it right? both as system variables?
Can you enter the following at the command prompt: echo %JAVA_HOME%
yep. it produces this line: C:\Program Files\Java\jdk1.6.0_45
One small correction, given that his appears to be a windows system. Rather than $JAVA_HOME\bin you should have %JAVA_HOME%\bin in your path.
Could you please try the following: At the command prompt enter: %JAVA_HOME%\bin\java.exe -version
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.