【软件版本说明】

软件名 版本号
jdk 1.8.121

1.一键安装jdk脚本

  1. #!/bin/bash
  2. #this shell to use installing jdk1.8.121
  3. echo "this shell to use installing jdk1.8.121 "
  4. echo "------------------start to install jdk----------------------"
  5. #sudo su #切换到root权限
  6. mkdir /usr/local/java
  7. cd /usr/local/java
  8. #download jdk 1.8.121
  9. #wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz
  10. wget https://coding.net/u/jamesz2011/p/ubuntu_lib/git/raw/master/jdk/jdk-8u121-linux-x64.tar.gz
  11. #extract jdk
  12. tar -xvf jdk-8u121-linux-x64.tar.gz
  13. #set environment
  14. export JAVA_HOME="/usr/local/java/jdk1.8.0_121"
  15. if ! grep "JAVA_HOME=/usr/local/java/jdk1.8.0_121" /etc/profile
  16. then
  17. echo "JAVA_HOME=/usr/local/java/jdk1.8.0_121" | sudo tee -a /etc/profile
  18. echo "export JAVA_HOME" | sudo tee -a /etc/profile
  19. echo "JRE_HOME=${JAVA_HOME}/jre" | sudo tee -a /etc/profile
  20. echo "export JRE_HOME" | sudo tee -a /etc/profile
  21. echo "CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" | sudo tee -a /etc/profile
  22. echo "export CLASSPATH" | sudo tee -a /etc/profile
  23. echo "PATH=${JAVA_HOME}/bin:$PATH" | sudo tee -a /etc/profile
  24. echo "export PATH" | sudo tee -a /etc/profile
  25. fi
  26. #update profile
  27. #source /etc/profile
  28. sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.8.0_121/bin/java 300
  29. sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.8.0_121/bin/javac 300
  30. echo "------------------end to install jdk------------------------"

2.install_jdk.sh文件地址:

3.用法:

  1. wget https://coding.net/u/jamesz2011/p/ubuntu_lib/git/raw/master/jdk/install_jdk.sh
  2. sudo chmod a+x install_jdk.sh
  3. sudo source install_jdk.sh

4.验证是否安装成功:

输入 java -versoin [若出现版本号,则安装成功]