Home > database >  Java version is not changing on windows
Java version is not changing on windows

Time:06-02

Previously I had java 1.8.0_131, then I installed JDK 1.8.0_102. Then changed the version in environment variables also, but while checking java version in cmd it's still showing java 1.8.0_131. Any solution to this?

CodePudding user response:

I guess you have already tried the obvious ways with paths etc, so maybe you broke the symbolic links.

So, try to write the following commands in the terminal with elevated rights:

mklink java.exe "C:\Program Files\Java\jdk1.8.0_131\bin\java.exe"
mklink javaw.exe "C:\Program Files\Java\jdk1.8.0_131\bin\javaw.exe"
mklink javaws.exe "C:\Program Files\Java\jdk1.8.0_131\bin\javaws.exe"

(Adjust the path according to the paths of your computer)

CodePudding user response:

Make sure that you have installed only 1 version of java 1.8 and uninstall the others in the control panel like this:

control panel programs

CodePudding user response:

Please follow instructions in first part of this tutorial How to Change Java Versions in Windows for setting your default Java version, then use Windows batch files such as these for changing active version anytime you need change version to another:

ActivateJava_8.bat:

@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
setx JAVA_HOME "%JAVA_HOME%"
set Path=%JAVA_HOME%\bin;%Path%
echo Java 8 activated as user default.

ActivateJava_11.bat

@echo off
set JAVA_HOME=C:\Program Files\Java\jdk-11.0.12
setx JAVA_HOME "%JAVA_HOME%"
set Path=%JAVA_HOME%\bin;%Path%
echo Java 11 activated as user default.

Change JAVA_HOME based on your installed version and directory.

  • Related