Sean2014
Sean2014

Reputation: 531

What would be the reason for that the Java version is NOT updated when Javac version is successfully updated?

I installed Java version 10.0.2 a few years ago, but need to update it to 11.0.2 for a particular purpose (not the latest version 13.0.2. I need it be 11.0.2).

After downloading jdk-11.0.2, I opened the environment variable window and made a change as the followings.

New path added

editing the path

Path updated

enter image description here

But when I checked the Java version by the command prompt, it was still 10.0.2 even though Javac version was updated to 11.0.2.

enter image description here

How is it possible that Java version is not updated when Javac version gets successfully updated? It would be understandable if Javac hadn't been updated either though...

What can be the cause, and how can I fix this?

Upvotes: 1

Views: 1332

Answers (2)

Islam Hassan
Islam Hassan

Reputation: 712

Unlike all other user variables, the user path variable doesn't override the system path variable but gets appended to it. Consequently what is happening here is that you have a path to the Oracle java installation at the very beginning of your path variable which is overriding the path that you added to the java 11 installation. The simplest solution will be to edit your system path variable and add the java 11 path at its beginning. However, have a look here for the best practices in adding java to your path.

Upvotes: 1

Edwin Buck
Edwin Buck

Reputation: 70909

When it's time to run a program, the program is searched independently of the surrounding other technologies. This means that your javac command might not be tightly coupled to your java command.

Check your path, which is typically controlled by your PATH environmental variable. If it is finding a newer java than a javac, odds are you have a "JRE" on the PATH (which omits the "JDK" additions of compilers and other tools) before your "JVM" additions (which contain your java commands). Even if my "stab in the dark" is 100% incorrect, your PATH environmental variable is the key to unlocking the issue.

Upvotes: 0

Related Questions