1

I want to install the new 11.0.02 java jdk. I tried to use this link: first source

and afterwards this: second source

Now, using cmd, I run these two commands:

  1. java -version ==> the older version gets printed.
  2. javac -version the new java jdk 11.0.02.

My question is: Why do they differ and how do I ensure that the latest version is the default?

3

2 Answers 2

0

On Linux, if you have both (or more) versions installed, you can use the following command to select the active one:

sudo update-alternatives --config java
1
  • Oh. Then excuse me, I'm currently running a Linux variant. I'm going to leave this answer here for Linux users, but I cannot help you.
    – zx485
    Mar 31, 2019 at 23:52
0

In my experience, if you've got a JRE installed, then install a JDK, the path for java.exe etc. will stay pointing at the JRE.

I hope I've answered your two questions, why are they different (because of the order of your path), and how to make the latest one the one that executes (by either installing the latest JRE or else fixing your path by hand) in the details below:

$ where java

C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe

C:\Program Files (x86)\Java\jdk1.8.0_121\bin\java.exe

C:\ProgramData\Oracle\Java\javapath\java.exe

$ which java [btw, which is a GNU tool, not built into Windows]

C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.EXE

$ path

PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Java\jdk1.8.0_121\bin;

$ "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe" -version

java version "1.8.0_201"

Java(TM) SE Runtime Environment (build 1.8.0_201-b09)

Java HotSpot(TM) Client VM (build 25.201-b09, mixed mode)

$ "C:\Program Files (x86)\Java\jdk1.8.0_121\bin\java.exe" -version

java version "1.8.0_121"

Java(TM) SE Runtime Environment (build 1.8.0_121-b13)

Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode, sharing)

(Pretending for the moment my JDK version of java was the newer one) I could update the JRE separately and it would probably fix things by putting the correct new version in Common Files for me, or I might just edit my path to put C:\Program Files (x86)\Java\jdk1.8.0_121\bin; in front of C:\Program Files (x86)\Common Files\Oracle\Java\javapath;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .