简体   繁体   中英

Java version is not changing on windows

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 the Java version in cmd it's still showing Java 1.8.0_131 . Any solution to this?

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)

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 switching between Java versions:

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.

To check that Environment variables are changed as expected, run following commands on command line:

echo %JAVA_HOME%
echo %path%

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM