I'm trying to learn how to quickly change which java version my system uses as described in this article: https://aboullaite.me/switching-between-java-versions-on-ubuntu-linux/ I've used apt-get install openjdk-8-jdk, and when I run sudo update-alternatives --config java it looks like this:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 manual mode
* 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
I'm trying to create a script that will switch between versions, like in the article. (this is the script from the article:
sudo update-java-alternatives -s java-8-oracle
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/
export PATH=$PATH:$JAVA_HOME
but when I try it, this happens:
sudo update-java-alternatives -s java-8-openjdk-amd64
update-java-alternatives: file does not exist: /usr/lib/jvm/.java-8-openjdk-amd64.jinfo
How can I update-java-alternatives without an error? Should I just skip that line?