Reputation: 2886
As depicted in above image java home is set and is being echoed but when i check for version it gives me latest version. Already restarted the command prompt after setting env variable. OS is Windows 7
Update:
Following is the Path.
..ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;;%JAVA_HOME%/bin;
Upvotes: 8
Views: 28691
Reputation: 199
Windows has this peculiar way of considering JAVA version. By default there is a java folder where jre is placed by windows. It is under C:\Program Files (x86)\Java\jre1.8.0_351.
And when you will read your Environment variable in windows 10 onward, you will notice there is a path entry "C:\Program Files (x86)\Common Files\Oracle\Java\javapath". This messes up with Custom java home that we declare. To fix this just move up the "%JAVA_HOME%/bin" as a first entry in path variable.
Upvotes: 2
Reputation: 18612
I had the same trouble and I solved it with the following steps:
You need the correct environment variables.
To be exactly correct, you only need to set the Path
variable.
You need to find where you add %JAVA_HOME%\bin
to the path.
Put it at first place in the Path
variable:
%JAVA_HOME%\bin;...
where ...
represents all other values of Path
.
I assume that JAVA_HOME
is defined as a variable and had the correct value.
After this reopen console and check:
java -version
Upvotes: 23
Reputation: 8388
I think in your path
variable you have hardcoded the path to bin
folder. it should always be %JAVA_HOME%/bin
.
So that it can pick path from JAVA_HOME
variable and you don't need to change both the variables every time.
Upvotes: 0
Reputation: 2119
Check your PATH
environment variable also. Your system is referring to latest Java installation through PATH variable.
Upvotes: 0
Reputation: 240966
JAVA_HOME
is environment variable that various application reads in their launcher script
when you invoke java
it looks up for all paths specified in your env variable named PATH
and wherever the first match is it gets picked up
so if you like command prompt to refer to jdk 6's Java append the path to PATH
Upvotes: 2
Reputation: 13566
You need to add the path to jJAVA_HOME%/bin
directory in the path
variable too. java
command is located in %JAVA_HOME%/bin
Upvotes: 0