View all java versions
lwk@qwfys:
$ update-java-alternatives --list java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64 java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64 lwk@qwfys:$switch java version
lwk@qwfys:~$ sudo update-alternatives --config java 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 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
- 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press
to keep the current choice[*], or type selection number: 1 update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/java to provide /usr/bin/java (java) in manual mode lwk@qwfys:~$ step write JAVA_HOME to file
lwk@qwfys:
$ echo $"export JAVA_HOME=$(readlink -f /usr/bin/java | sed 's:jre/bin/java::')" |sudo tee /etc/profile.d/java.sh export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/java lwk@qwfys:$step Activate variable value
. /etc/profile.d/java.sh
step View the changed value
lwk@qwfys:
$ echo $JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/bin/java lwk@qwfys:$
How to switch java version on ubuntu 20.04
点赞
收藏