I have a Windows 10 x64 machine. I had Open JDK 10. My JAVA_HOME
points to Open JDK 10 location. My Path
variable has %JAVA_HOME%/bin;
part.
Then I installed Java 8. https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Java installer changes Path
.
C:\Users\user>set Path
Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;OTHER_STUFF_WITHOUT_JAVA
Now in command line java -version
points to Java 8.
C:\Users\user>java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
But JAVA_HOME
is still pointing to Open JDK 10.
C:\Users\user>set java_home
JAVA_HOME=C:\Java\jdk\jdk-10.0.2
My goal is to have Open JDK-10 as default Java.
This is not a duplicate Default Java Path on Windows Machines because there is no answer for me.
(Post comment as the answer for readability)
The easiest way to have several JDK and be sure to point towards the good one, is to avoid using the java installers. You should just unzip the JDKs in a folder and then modify your JAVA_HOME and PATH accordingly. You could also have several JAVA_HOME like JAVA_HOME_8 and JAVA_HOME_10 pointing to their respective JDK folder and make your JAVA_HOME=%JAVA_HOME_10% so you can change easily.
The easiest way i just found out is that the java 8 installer creates a new environment PATH entry:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
This will point to the latest installed JRE or JDK(i.e. the last in JDK or JRE) using the installer method.
So if your JAVA_HOME points to the JDK 10 OR JRE 10 just go to the Environment Variables and remove:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
From the PATH variable.
Then the values you used for JAVA_HOME will become effective.
This worked for me after installing java 8 and i had installed java 12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With