本文主要介绍Ubuntu下安装配置JDK10的方法,包括使用PPA源安装,手动安装和使用sdkman安装方法。

1、使用PPA源简单安装配置JDK10

1)安装命令

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

2)配置JDK10为默认

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

3)验证安装

$ 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)

2、手动安装配置JDK10

JDK10下载地址https://jdk.java.net/10/

1)解压下载的文件

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

2)移动到系统保存已安装JDK的位置

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

3)添加新的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

4)更新系统的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

5)验证安装

$ 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

3、使用sdkman安装配置JDK10

sdkman安装https://sdkman.io/install

1)列出所有可用JDK版本

sdk list java

提示

==============================================================================
Available Java Versions
==============================================================================
9.0.4-open
+ 8u161-oracle
8.0.191-oracle
> + 8.0.171-oracle
7.0.191-zulu
12.ea.15-open
11.0.1-open
10.0.2-open
1.0.0-rc8-graal
==============================================================================
+ - local version
* - installed
> - currently in use
==============================================================================

2)安装指定的JDK版本

sdk install java 10.0.2-open

提示

Downloading: java 10.0.2-open
In progress...
################# 12,3%

3)使用指定的JDK版本

sdk use java 10.0.2-open

提示

Using java version 10.0.2-open in this shell.

相关文档Java jdk11 在Linux上的安装和配置

Linux Ubuntu Java Jdk10 安装命令和手动下载安装方法

推荐文档

相关文档

大家感兴趣的内容

随机列表