一、删除OpenJDK:

 
sudo apt-get purge openjdk*

  

二、添加PPA:

 root@ubuntu:~# add-apt-repository ppa:webupd8team/java
The program 'add-apt-repository' is currently not installed. You can install it by typing:
apt install software-properties-common

  

 
以上提示是因为add-apt-repository命令不存在,安装即可:
 apt install software-properties-common

  

 然后在执行添加PPA的命令:
 
root@ubuntu:~# add-apt-repository ppa:webupd8team/java
Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK7 / JDK8 / JDK9). There are no actual Java files in this PPA. More info (and Ubuntu installation instructions):
- for Oracle Java 7: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
- for Oracle Java 8: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html Debian installation instructions:
- Oracle Java 7: http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html
- Oracle Java 8: http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html Oracle Java 9 (for both Ubuntu and Debian): http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html For JDK9, the PPA uses standard builds from: https://jdk9.java.net/download/ (and not the Jigsaw builds!). Important!!! For now, you should continue to use Java 8 because Oracle Java 9 is available as an early access release (it should be released in 2016)! You should only use Oracle Java 9 if you explicitly need it, because it may contain bugs and it might not include the latest security patches! Also, some Java options were removed in JDK9, so you may encounter issues with various Java apps. More information and installation instructions (Ubuntu / Linux Mint / Debian): http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html
More info: https://launchpad.net/~webupd8team/+archive/ubuntu/java
Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keyring `/tmp/tmp08u3_3hk/secring.gpg' created
gpg: keyring `/tmp/tmp08u3_3hk/pubring.gpg' created
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp08u3_3hk/trustdb.gpg: trustdb created
gpg: key EEA14886: public key "Launchpad VLC" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK

  

三、更新源:

 
sudo apt-get update

四、安装JDK1.8:

 
sudo apt-get install oracle-java8-installer
 
修改数字为6、7后,将会安装java6 (or 7)。

五、设置默认的jdk(配置环境变量):

 sudo apt-get install oracle-java8-set-default
 
同样,修改数字为6 or 7 以后,将设置默认的java版本为6 or 7

六、查看版本:

 
root@ubuntu:~# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
 
版本切换:
 
sudo update-java-alternatives -s java-8-oracle

卸载JDK:

 
sudo apt-get remove oracle-java8-installer

最新文章

  1. dotnet webapi 中添加Swagger文档
  2. 20145205 java语言实现数据结构实验一
  3. hihoCoder#1000
  4. 之四:CATransition - 转场动画
  5. lucene-查询query->PhrasePrefixQuery使用短语缀搜索
  6. 科研论文提交流程与常见问题(EDAS 系统提交)
  7. Shell终端收听音乐--豆瓣FM命令行版
  8. kafka在windows下的安装和配置
  9. SSH复用代码最终版
  10. sql sever[基本] ''增删改'' 随笔
  11. linux系统命令学习系列-定时任务crontab命令
  12. [SDOI2014]重建
  13. pyhton崩溃的第六天,又有新成员
  14. VS2013 创建ASP.NET MVC 4.0 未指定的错误(异常来自HRESULT: 0x80004005(e_fail))
  15. 【clustering】之K-means && K-medoids
  16. 后台获取url里面加密的参数中,特殊符号+获取到后端后是 一个空格的解决方法
  17. opencv的安装及填坑
  18. pyhon基础之约束和异常处理:
  19. 2018.08.04 spoj TTM to the moon(主席树)
  20. module、applet

热门文章

  1. sql 条件插入
  2. mysql数据库,编码错误解决
  3. scrapy学习-爬取天天基金网基金列表
  4. Asp.Net生命周期系列一
  5. PAT 1086 就不告诉你
  6. 【历史】- UNIX发展史(BSD,GNU,linux)
  7. elementUI中的el-form怎么使用正则进行验证
  8. tomcat 路径"/"表示根目录
  9. BZOJ4488 JSOI2015最大公约数
  10. [codeforces] 17E Palisection