系统相关
首页 > 系统相关> > 如何在Ubuntu下安装JDK 10?

如何在Ubuntu下安装JDK 10?

作者:互联网

如何在Ubuntu上安装Java Development Kit(JDK)10?

Oracle帮助中心的installation instructions仅解释了如何在Linux平台上下载和解压缩归档,无需任何系统设置.

解决方法:

更新:JDK 11现已推出

sudo apt-get install openjdk-11-jdk

对于JDK 10

选项1:易于安装(PPA)

sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java10-installer

然后设置为默认值:

sudo apt-get install oracle-java10-set-default

最后验证安装:

$java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

资料来源:Linux Uprising

选项2:手动安装

>下载适用于Linux的OpenJDK 10二进制文件.
>解压下载的档案:

tar xzvf openjdk-10_linux-x64_bin.tar.gz

>将提取的存档移动到系统保存已安装JDK的位置:

sudo mv jdk-10 /usr/lib/jvm/java-10-openjdk-amd64/

>添加新的Java替代方案:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-10-openjdk-amd64/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-10-openjdk-amd64/bin/javac 1

>更新系统的Java替代品并选择JDK 10:

$sudo update-alternatives --config java
here are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      auto mode
* 1            /usr/lib/jvm/java-10-openjdk-amd64/bin/java      1         manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  3            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode

Press <enter> to keep the current choice[*], or type selection number: 

$sudo update-alternatives --config javac
There are 3 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-9-openjdk-amd64/bin/javac    1091      auto mode
  1            /usr/lib/jvm/java-10-openjdk-amd64/bin/javac   1         manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/bin/javac    1081      manual mode
  3            /usr/lib/jvm/java-9-openjdk-amd64/bin/javac    1091      manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/java-10-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in manual mode

>验证您的安装:

$java --version
openjdk 10 2018-03-20
OpenJDK Runtime Environment 18.3 (build 10+46)
OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)

$javac --version
javac 10

>完成

如果您更喜欢Oracle的JDK,download it并按照上面所示的安装步骤操作.

标签:java-10,java,ubuntu
来源: https://codeday.me/bug/20190918/1811597.html