Boommeister
Boommeister

Reputation: 2107

Set Environment variables to Java 11 directory, but CLI -> Java -version is still 1.8?

I have restarted my cmd line after setting the environment variables. Javac is set to version 11, but java is still set to 8?

Java -version in CLI

I have set my path variables like this:

my path variables

There are no entries from other java versions in my Path variables like in this question: Installed Java 14 but Java -version still showing old Java

I have double checked that java.exe and javac.exe are in fact at location C:\Program Files\Java\jdk-11.0.7\bin:

my Java 11 Folder

I have read the other questions to this problem on Stackoverflow, but it was always that they set a wrong path, forgot to append /bin or had old paths to other java versions in their environment variables. I also tried reinstalling Java 11 and restarting the computer (as last idea). What else could I try?

Upvotes: 6

Views: 12658

Answers (4)

Komal
Komal

Reputation: 200

I made 2 changes in order to reflect java -version as Java11

  1. Control Panel --> Edit environment variables for ur account -->System Variables --> Path
  2. Make sure %JAVAHOME%\bin should be on 1st place
  3. Make sure C:\Program Files\Common Files\Oracle\Java\javapath should be on 2nd place.

Upvotes: 0

Arvind Kumar Avinash
Arvind Kumar Avinash

Reputation: 79075

Move %JAVA_HOME%\bin to the top and then check java -version in a new cmd window. Make sure you do it in both, User variables as well System variables. Check this to learn more about a similar problem and its solution.

Upvotes: 4

f.trajkovski
f.trajkovski

Reputation: 825

You can also put in your system variables:

  • Click on Path
  • Edit
  • Click on New
  • Add the whole path something like: C:\Program Files\Java\jdk11.0_172\bin (this should be your path where the jdk is installed).

This will work and you will have java 11.

Upvotes: 1

Linora
Linora

Reputation: 10988

This can be caused by multiple different reasons.

Try 'where java' and 'where javac' to see where they point to. You should thenbe able to find the exact path from where java and javac are being called in your environment.

Also ensure that you only have one jdk/jre in your Path. You can try to move %JAVA_HOME% to be the first element in the Path list.

Upvotes: 4

Related Questions