其他分享
首页 > 其他分享> > JDK 1.8安装

JDK 1.8安装

作者:互联网

JDK 1.8安装

shell脚本安装

cd /usr/local/
wget https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.tar.gz
tar -xf jdk-8u201-linux-x64.tar.gz
ln -sv jdk1.8.0_201 jdk1.8
echo 'export JAVA_HOME=/usr/local/jdk1.8' >> /etc/profile 
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile 
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile 

source /etc/profile
cp /usr/local/jdk1.8/bin/* /bin/
java -version  && echo -e '\033[32m java部署成功\033[0m' || echo -e '\033[31m java部署失败\033[0m'

 

 

ansible-playbook安装

---
- hosts: h5
  remote_user: yunwei
  become: yes
  become_user: root
  become_method: sudo
  gather_facts: flase
  tasks:

  - name: 'package'
    shell: cd /usr/local/
    shell: wget https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.tar.gz
    shell: tar -xf jdk-8u201-linux-x64.tar.gz &> /dev/null
    shell: ln -sv jdk1.8.0_201 jdk1.8


  - name: 'export path'
    shell: echo 'export JAVA_HOME=/usr/local/jdk1.8' >> /etc/profile 
    shell: echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile 
    shell: echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile 

   - name: java path
    shell: cp /usr/local/jdk1.8/bin/* /bin/
    shell: source /etc/profile

  - name: check java version
    shell: java -version



$ansible-playbook -i h5 -C java.yaml

$ansible-playbook -i h5 java.yaml
 

 

标签:profile,jdk1.8,shell,java,JDK,1.8,etc,HOME,安装
来源: https://www.cnblogs.com/weiweirui/p/16598352.html