jdk1.8脚本安装
2019-03-12 本文已影响0人
Daisy小朋友
#!/usr/bin/env bash
##f4198016c840e227bb185bb1c1042a9f jdk-8u201-linux-x64.tar.gz
##如果不能解压,注意md5值
url="http://192.168.1.202:9000/jdk-8u201-linux-x64.tar.gz"
jdk="jdk-8u201-linux-x64.tar.gz"
version="jdk1.8.0_201"
if which java >/dev/null; then
echo "Java exists, and then exit."
exit
fi
if [ ! -f /tmp/$jdk ]; then
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=a" $url -O /tmp/$jdk 2>&1
fi
if [ ! -d /usr/java ]; then
mkdir -p /usr/java
fi
tar -xzf /tmp/$jdk -C /usr/java
if [ -z $JAVA_HOME ]; then
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_201' >>/etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >>/etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >>/etc/profile
source /etc/profile
fi
echo "Finished"