Ubuntu 18.04安装Java JDK8三种方式
1/
sudo apt-get update
sudo apt-get install openjdk-8-jdk
java -version
2/
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
3/
sudo mkdir /usr/lib/jvm
sudo tar -zxvf jdk-7u60-linux-x64.gz -C /usr/lib/jvm
sudo vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_191 ## 这里要注意目录要换成自己解压的jdk 目录
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source ~/.bashrc
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_191/bin/java 300
java -version
sudo update-alternatives –config java (多个java版本切换)