ubuntu java1.7 升級 java 1.8
阿新 • • 發佈:2019-01-21
1 下載對應版本的安裝包
2 解壓後複製到 usr/lib/jvm/目錄下
tar -xzvf jdk-8u131-linux-i586.gz
sudo mv jdk1.8.0_131 /usr/lib/jvm/jdk1.8.0_131
3 更新jdk
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_131/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_131/bin/javac 1
根據提示輸入相應的數字
sudo update-alternatives --config java
sudo update-alternatives --config javac
4 配置java_home變數
$echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-i386
$ sudo echo export JAVA_HOME="/usr/lib/jvm/jdk1.8.0_131/" >> ~/.bashrc
$source ~/.bashrc
$echo
$JAVA_HOME
$source /etc/profile