CentOS 7 shell安装JDK Tomcat

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash
# shell script to install jdk 


# 1. remove openjdk if exists.
for i in $(rpm -qa | grep jdk | grep -v grep)
do
  echo "Deleting rpm -> "$i
  rpm -e --nodeps $i
done

if [[ ! -z $(rpm -qa | grep jdk | grep -v grep) ]];
then 
  echo "-->Failed to remove the defult Jdk."
else 




# 2.unzip and install JDK(jdk-6u45-linux-x64.bin)
  
  tar -zxvf jdk-7u71-linux-x64.tar.gz
  mkdir /usr/java
  mv ./jdk1.7.0_71 /usr/java/jdk1.7.0_71
  rm -rf ./jdk1.7.0_71
 
 
    
  


  # 3. config /etc/profile


  echo "export JAVA_HOME=/usr/java/jdk1.7.0_71" >>/etc/profile
  echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'>>/etc/profile
  echo 'export PATH=$PATH:$JAVA_HOME/bin'>>/etc/profile
       

  source /etc/profile  

fi