D
D
Dmitry2022-03-24 12:15:09
Java
Dmitry, 2022-03-24 12:15:09

Am I switching java versions correctly?

I use windows 10, installed java 8 and java 11 (in that order). For switching, I do not plan to use third-party software like SDKMAN.

Do I understand correctly that to switch you just need to change JAVA_HOME and Path?
Made variables

JAVA_HOME_8 = C:\Program Files\Java\jdk1.8.0_311
JAVA_HOME_11 = C:\Program Files\Java\jdk-11.0.13
JAVA_HOME = %JAVA_HOME_8%


And added to Path
%JAVA_HOME%\bin

After that, the versions did not switch, java -version showed 11 all the time. After reassigning the variables, I did not forget to press OK in the "Environment Variables" window and restart the console, if anything.

I had to remove these lines from Path (in the "System Variables" section)
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files (x86)\Common Files\Oracle\Java\javapath


After that the versions started switching, the compilation works with the correct version. I checked it using var - on version 8 it gives an error, on version 11 it compiles normally.

Hence the question - will this removal backfire in other cases, about which I do not know now?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2022-03-24
@shebbs

Correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question