Ubantu 16.04 用apt-get自動安裝oracle java

NO IMAGE

每次安裝都要查一遍,索性記錄一下。

首先執行:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

對於需要的java版本,繼續執行:

  • Oracle JDK 6: sudo apt-get install oracle-java6-installer
  • Oracle JDK 7: sudo apt-get install oracle-java7-installer
  • Oracle JDK 8: sudo apt-get install oracle-java8-installer

預設最新版

reference:https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get

關於ubantu換源:

  1. cd /etc/apt 檢視是否有sources.list檔案
  2. sudp cp sources.list sources.list1 備份原來的原始檔
  3. sudo nano sources.list 編輯原始檔刪除原來的內容並填入(國內163的源):

    deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
  4. 儲存退出,執行sudo apt-get update檢查換源是否成功

reference: http://jingyan.baidu.com/article/925f8cb8f3af25c0dde05681.html