1. 添加 Java 8 PPA源
编辑一个新的ppa文件:
$ sudo vim /etc/apt/sources.list.d/java-8-debian.list
往文件中添加以下内容:
1 2 |
deb http://ppa<span class="hljs-preprocessor">.launchpad</span><span class="hljs-preprocessor">.net</span>/webupd8team/java/ubuntu trusty main deb-src http://ppa<span class="hljs-preprocessor">.launchpad</span><span class="hljs-preprocessor">.net</span>/webupd8team/java/ubuntu trusty main |
- 1
- 2
然后导入GPG key:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
2. 安装Java 8
使用以下命令来更新apt缓存并安装java8
1 2 |
$ sudo apt<span class="hljs-attribute">-get</span> update $ sudo apt<span class="hljs-attribute">-get</span> install oracle<span class="hljs-attribute">-java8</span><span class="hljs-attribute">-installer</span> |
- 1
- 2
3. 配置 JAVA环境
使用以下命令可以快速设置环境变量
$ sudo apt-get install oracle-java8-set-default