一鍵更換
function just_do_it(){
echo '系統(tǒng)自帶openjdk版本是:'java -version
echo '1.開(kāi)始卸載openjdk'
yum remove "*openjdk*" -y
echo '卸載系統(tǒng)自帶openjdk成功'
echo '2.創(chuàng)建sunjdk文件夾所在位置'
mkdir -p /usr/local/java && cd /usr/local/java
echo '創(chuàng)建sunjdk文件夾成功'
echo '4.下載文件'
#wget https://download.oracle.com/otn/java/jdk/8u261-b12/a4634525489241b9a9e1aa73d9e118e6/jdk-8u261-linux-x64.tar.gz?AuthParam=1599464260_6014d8d3083aaa13876765204ca4043d
# 下載不到j(luò)dk的話去百度云盤,鏈接在此
#鏈接: https://pan.baidu.com/s/1-3pl106l0IxPvql-VXJjZw 提取碼: ugnh
#mv /usr/local/src/jdk-8u261-linux-x64.tar.gz .
echo '解壓'
tar -zxvf jdk-8u261-linux-x64.tar.gz
echo '5.添加配置文件'
echo
'export JAVA_HOME=/usr/local/java/jdk1.8.0_261
export JRE_HOME=/usr/local/java/jdk1.8.0_261/jre
export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH'
>> ~/.bash_profile
sleep 5
echo '6.建立軟連接'
ln -s /usr/bin/java /usr/local/java/
echo 'sunjdk版本號(hào)為:'
java -version
echo 'jdk版本升級(jí)完成'
}
# 入口
just_do_it
source ~/.bash_profile
rm -rf /usr/bin/java && ln -s /usr/local/java/jdk1.8.0_261/bin/java /usr/bin/java
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者