JDK8在线安装异常以及安装方式
常见错误
- 安装ppa
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
自写这篇文档得时候会出现如下提示,大概意思就是说oracle更新下载需要用户登录,java 7和java 6 没法使用这个更新啦。
The Oracle JDK License has changed for releases starting April 16, 2019.
The new Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle JDK licenses. The new license permits certain uses, such as personal use and development use, at no cost -- but other uses authorized under prior Oracle JDK licenses may no longer be available. Please review the terms carefully before downloading and using this product. An FAQ is available here: https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html
Oracle Java downloads now require logging in to an Oracle account to download Java updates, like the latest Oracle Java 8u211 / Java SE 8u212. Because of this I cannot update the PPA with the latest Java (and the old links were broken by Oracle).
For this reason, THIS PPA IS DISCONTINUED (unless I find some way around this limitation).
Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK8). There are no actual Java files in this PPA.
Important -> Why Oracle Java 7 And 6 Installers No Longer Work: http://www.webupd8.org/2017/06/why-oracle-java-7-and-6-installers-no.html
Update: Oracle Java 9 has reached end of life: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html
The PPA supports Ubuntu 18.10, 18.04, 16.04, 14.04 and 12.04.
More info (and Ubuntu installation instructions):
- http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
Debian installation instructions:
- Oracle Java 8: http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html
For Oracle Java 11, see a different PPA -> https://www.linuxuprising.com/2019/06/new-oracle-java-11-installer-for-ubuntu.html
More info: https://launchpad.net/~webupd8team/+archive/ubuntu/java
Press [ENTER] to continue or Ctrl-c to cancel adding it.
- 安装jdk
$ sudo apt-get install oracle-java8-installer
执行之后会报如下错误,根据上面得提示这里正常是没法从这里安装的
$ sudo apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package oracle-java8-installer is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'oracle-java8-installer' has no installation candidate
正确的打开方式
摘自这位大哥的链接
1、官网下载jdk
下载链接
http://www.oracle.com/technetwork/java/javase/downloads/index.html
可以根据自己的系统进行下载
2、进行解压
sudo tar -zxvf jdk-8u171-linux-x64.tar.gz 则解压到了当前目录下,解压后可以把解压文件移动到自己想要放的目录下,使用mv命令 sudo mv jdk1.8.0_231 /usr/lib/jdk1.8.0_231
3、进行配置
使用全局设置方法,它是所有用户的共用的环境变量
命令如下:$sudo gedit ~/.bashrc
然后把如下命令复制到最底部
export JAVA_HOME=/usr/lib/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export JAVA_HOME=后面要填写自己解压后的jdk的路径
4、生效~/.bashrc文件
命令如下:$sudo source ~/.bashrc
5、测试是否安装成功
java -version 查看版本号是否改变