How to change Java version on Windows 10
I have done the following:
1. Set the environment variable JAVA_HOME:
2. Add Java 1.6.0_45 and disable Java 1.8.0_66 in Java Runtime Environment Settings under Configure Java:
Unfortunately, the Java is still 1.8.0_66:
>java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)
Could anyone offer a tip on this?
Edit:
Per David's suggestion, the following is the Java related contents from the output of command PATH (the entire output is super long, I hope the following is sufficient for this question.):
PATH=C:\ProgramData\Oracle\Java\javapath; ... C:\Program Files\Java\jdk1.6.0_45\bin
java -version
is running the wrong version of java.
Diagnostics:
>java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)
the following is the Java related contents from the output of
PATH
:
PATH=C:\ProgramData\Oracle\Java\javapath; ... C:\Program Files\Java\jdk1.6.0_45\bin
Conclusion:
From the above output we can deduce that C:\ProgramData\Oracle\Java\javapath
is 1.8.0_66
.
You need to change your PATH
to put C:\Program Files\Java\jdk1.6.0_45\bin
first.
I noticed that after checking the path per your suggestion. Windows 10 does not allow me to edit the path because it says "This environment variable is too large." I know there should be another question to deal with this separately.
You also need to clean up your path. My guess is you have a lot of duplicate entries.
I have the same problem, I have set JAVA_HOME
:
C:\Program Files\Java\jdk1.7.0_75
and Path
to:
%JAVA_HOME%\bin
I need run jdk 7. When I run java -version
it always appear jdk 8.
I solved it with: in System Environment --> Path --> order %JAVA_HOME%\bin
to first.
This is the REAL active JAVA executable into your PATH:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
Remove it and the system take the value from
...;%JAVA_HOME%\bin\;
As you can check the javapath variable under system's environment path variable.
So if you want to use your own version.You can do
- 1) Create new variable in systems variable
- 2) Name it as JAVA_HOME and give jdk installation path
- 3) add this variable in path and move it to top.
- 4) check java -version
you need to create a JAVA_HOME