Pre-Install
sudo apt-get install software-properties-common
https://packages.ubuntu.com/zh-tw/trusty/software-properties-common
Install Oracle Java8
sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
sudo apt-get update
sudo apt-get install oracle-java8-installer
javac -version
Install Oracle Java9
sudo apt-get install oracle-java9-installer
Java version manager
sudo update-alternatives --config java
SET JAVA_HOME
Modified ~/.profile
vim ~/.profile
Append JAVA_HOME
to environment
# JAVA_HOME
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
# JAVA version manange controller aliases
alias jvc='sudo update-alternatives --config java'
Verify
source ~/.profile
echo $JAVA_HOME
jvc
jerry@local:~$ jvc
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-9-oracle/bin/java 1091 auto mode
* 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode
2 /usr/lib/jvm/java-9-oracle/bin/java 1091 manual mode
Press enter to keep the current choice[*], or type selection number: 1
沒有留言:
張貼留言