Install Openjdk11 to Ubuntu 18.04 LTS

??Ubuntu 18.04 LTS系统上通过sudo apt install openjdk-11-*命令安装的jdk11版本依然是jdk10,怎么样才能安装openjdk 11呢,今天,我们就来完成这一工作。

download software package

[email protected]:~$sudo curl -sL https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -o /usr/lib/jvm/openjdk-11.0.1_linux-x64_bin.tar.gz

unzip package

[email protected]:~$cd /usr/lib/jvm/
[email protected]:/usr/lib/jvm$
[email protected]:/usr/lib/jvm$sudo tar -zxvf openjdk-11.0.1_linux-x64_bin.tar.gz
[email protected]:/usr/lib/jvm$ ll
total 32
drwxr-xr-x   5 root root  4096 Jan  4 02:27 ./
drwxr-xr-x 153 root root 12288 Dec 27 02:17 ../
lrwxrwxrwx   1 root root    20 Nov 20 09:07 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
-rw-r--r--   1 root root  2600 Nov 20 09:07 .java-1.8.0-openjdk-amd64.jinfo
drwxr-xr-x   8 root root  4096 Jan  4 01:42 java-8-openjdk-amd64/
drwxr-xr-x   8 root root  4096 Jan  4 02:04 jdk-11.0.1/
drwxr-xr-x   2 root root  4096 Jan  4 01:42 openjdk-8/
[email protected]:/usr/lib/jvm$

config

update-alternatives install

[email protected]:/usr/lib/jvm$ cd jdk-11.0.1/bin/
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$ ll
total 516
drwxr-xr-x 2 root root   4096 Jan  4 02:04 ./
drwxr-xr-x 8 root root   4096 Jan  4 02:04 ../
-rwxr-xr-x 1  668  668  12952 Oct  6 20:17 jaotc*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jar*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jarsigner*
-rwxr-xr-x 1  668  668   8672 Oct  6 20:17 java*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 javac*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 javadoc*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 javap*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jcmd*
-rwxr-xr-x 1  668  668  12888 Oct  6 20:17 jconsole*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jdb*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jdeprscan*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jdeps*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jhsdb*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jimage*
-rwxr-xr-x 1  668  668  12880 Oct  6 20:17 jinfo*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 jjs*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 jlink*
-rwxr-xr-x 1  668  668  12880 Oct  6 20:17 jmap*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jmod*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jps*
-rwxr-xr-x 1  668  668   8792 Oct  6 20:17 jrunscript*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jshell*
-rwxr-xr-x 1  668  668  12880 Oct  6 20:17 jstack*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jstat*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jstatd*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 keytool*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 pack200*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 rmic*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 rmid*
-rwxr-xr-x 1  668  668   8744 Oct  6 20:17 rmiregistry*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 serialver*
-rwxr-xr-x 1  668  668 117656 Oct  6 20:17 unpack200*
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$sudo sh -c ‘for bin in /usr/lib/jvm/jdk-11.0.1/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done‘
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$sudo sh -c ‘for bin in /usr/lib/jvm/jdk-11.0.1/bin/*; do update-alternatives --set $(basename $bin) $bin; done‘
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$

set JAVA_HOME

[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$ cd /etc/profile.d/
[email protected]:/etc/profile.d$ vim jdk.sh
[email protected]:/etc/profile.d$ cat jdk.sh
export J2SDKDIR=/usr/lib/jvm/jdk-11.0.1
export J2REDIR=/usr/lib/jvm/jdk-11.0.1
#export PATH=$PATH:/usr/lib/jvm/jdk-11.0.1/bin
export JAVA_HOME=/usr/lib/jvm/jdk-11.0.1
[email protected]:/etc/profile.d$ 

view

[email protected]:~$ java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
[email protected]:~$ javac -version
javac 11.0.1
[email protected]:~$ 

??至此安装完成。

uninstall

remove ‘JAVA_HOME’

[email protected]:~$ sudo rm /etc/profile.d/jdk.sh
[email protected]:~$ 

update-alternatives uninstall

[email protected]:~$ cd /usr/lib/jvm/jdk-11.0.1/bin/
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$ ll
total 516
drwxr-xr-x 2 root root   4096 Jan  4 02:04 ./
drwxr-xr-x 8 root root   4096 Jan  4 02:04 ../
-rwxr-xr-x 1  668  668  12952 Oct  6 20:17 jaotc*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jar*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jarsigner*
-rwxr-xr-x 1  668  668   8672 Oct  6 20:17 java*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 javac*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 javadoc*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 javap*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jcmd*
-rwxr-xr-x 1  668  668  12888 Oct  6 20:17 jconsole*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jdb*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jdeprscan*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jdeps*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jhsdb*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jimage*
-rwxr-xr-x 1  668  668  12880 Oct  6 20:17 jinfo*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 jjs*
-rwxr-xr-x 1  668  668   8784 Oct  6 20:17 jlink*
-rwxr-xr-x 1  668  668  12880 Oct  6 20:17 jmap*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jmod*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jps*
-rwxr-xr-x 1  668  668   8792 Oct  6 20:17 jrunscript*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jshell*
-rwxr-xr-x 1  668  668  12880 Oct  6 20:17 jstack*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jstat*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 jstatd*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 keytool*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 pack200*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 rmic*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 rmid*
-rwxr-xr-x 1  668  668   8744 Oct  6 20:17 rmiregistry*
-rwxr-xr-x 1  668  668   8736 Oct  6 20:17 serialver*
-rwxr-xr-x 1  668  668 117656 Oct  6 20:17 unpack200*
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$ sudo sh -c ‘for bin in /usr/lib/jvm/jdk-11.0.1/bin/*; do update-alternatives --remove $(basename $bin) $bin; done‘
update-alternatives: removing manually selected alternative - switching jaotc to auto mode
update-alternatives: removing manually selected alternative - switching jar to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jar to provide /usr/bin/jar (jar) in auto mode
update-alternatives: removing manually selected alternative - switching jarsigner to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner to provide /usr/bin/jarsigner (jarsigner) in auto mode
update-alternatives: removing manually selected alternative - switching java to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: removing manually selected alternative - switching javac to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javac to provide /usr/bin/javac (javac) in auto mode
update-alternatives: removing manually selected alternative - switching javadoc to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javadoc to provide /usr/bin/javadoc (javadoc) in auto mode
update-alternatives: removing manually selected alternative - switching javap to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javap to provide /usr/bin/javap (javap) in auto mode
update-alternatives: removing manually selected alternative - switching jcmd to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jcmd to provide /usr/bin/jcmd (jcmd) in auto mode
update-alternatives: removing manually selected alternative - switching jconsole to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
update-alternatives: removing manually selected alternative - switching jdb to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jdb to provide /usr/bin/jdb (jdb) in auto mode
update-alternatives: removing manually selected alternative - switching jdeprscan to auto mode
update-alternatives: removing manually selected alternative - switching jdeps to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jdeps to provide /usr/bin/jdeps (jdeps) in auto mode
update-alternatives: removing manually selected alternative - switching jhsdb to auto mode
update-alternatives: removing manually selected alternative - switching jimage to auto mode
update-alternatives: removing manually selected alternative - switching jinfo to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jinfo to provide /usr/bin/jinfo (jinfo) in auto mode
update-alternatives: removing manually selected alternative - switching jjs to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode
update-alternatives: removing manually selected alternative - switching jlink to auto mode
update-alternatives: removing manually selected alternative - switching jmap to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jmap to provide /usr/bin/jmap (jmap) in auto mode
update-alternatives: removing manually selected alternative - switching jmod to auto mode
update-alternatives: removing manually selected alternative - switching jps to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jps to provide /usr/bin/jps (jps) in auto mode
update-alternatives: removing manually selected alternative - switching jrunscript to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jrunscript to provide /usr/bin/jrunscript (jrunscript) in auto mode
update-alternatives: removing manually selected alternative - switching jshell to auto mode
update-alternatives: removing manually selected alternative - switching jstack to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jstack to provide /usr/bin/jstack (jstack) in auto mode
update-alternatives: removing manually selected alternative - switching jstat to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jstat to provide /usr/bin/jstat (jstat) in auto mode
update-alternatives: removing manually selected alternative - switching jstatd to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jstatd to provide /usr/bin/jstatd (jstatd) in auto mode
update-alternatives: removing manually selected alternative - switching keytool to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: removing manually selected alternative - switching pack200 to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode
update-alternatives: removing manually selected alternative - switching rmic to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/rmic to provide /usr/bin/rmic (rmic) in auto mode
update-alternatives: removing manually selected alternative - switching rmid to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: removing manually selected alternative - switching rmiregistry to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: removing manually selected alternative - switching serialver to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/serialver to provide /usr/bin/serialver (serialver) in auto mode
update-alternatives: removing manually selected alternative - switching unpack200 to auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode
[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$

remove the java installation directory

[email protected]:/usr/lib/jvm/jdk-11.0.1/bin$ cd ../../
[email protected]:/usr/lib/jvm$ ll
total 32
drwxr-xr-x   5 root root  4096 Jan  4 02:27 ./
drwxr-xr-x 153 root root 12288 Dec 27 02:17 ../
lrwxrwxrwx   1 root root    20 Nov 20 09:07 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
-rw-r--r--   1 root root  2600 Nov 20 09:07 .java-1.8.0-openjdk-amd64.jinfo
drwxr-xr-x   8 root root  4096 Jan  4 01:42 java-8-openjdk-amd64/
drwxr-xr-x   8 root root  4096 Jan  4 02:04 jdk-11.0.1/
drwxr-xr-x   2 root root  4096 Jan  4 01:42 openjdk-8/
[email protected]:/usr/lib/jvm$ sudo rm -rf jdk-11.0.1/
[email protected]:/usr/lib/jvm$ ll
total 28
drwxr-xr-x   4 root root  4096 Jan  4 03:38 ./
drwxr-xr-x 153 root root 12288 Dec 27 02:17 ../
lrwxrwxrwx   1 root root    20 Nov 20 09:07 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
-rw-r--r--   1 root root  2600 Nov 20 09:07 .java-1.8.0-openjdk-amd64.jinfo
drwxr-xr-x   8 root root  4096 Jan  4 01:42 java-8-openjdk-amd64/
drwxr-xr-x   2 root root  4096 Jan  4 01:42 openjdk-8/
[email protected]:/usr/lib/jvm$ 

view

[email protected]:~$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
[email protected]:~$ javac -version
javac 1.8.0_191
[email protected]:~$ 

??至此卸载完成。

原文地址:https://www.cnblogs.com/jpfss/p/11106346.html

时间: 2024-11-07 22:50:20

Install Openjdk11 to Ubuntu 18.04 LTS的相关文章

Install golang on Ubuntu 14.04 LTS

1. Install golang on Ubuntu 14.04 LTS a)~$ sudo apt-get install golang                   success b)~$ sudo add-apt-repository ppa:gophers/go ~$ sudo apt-get update ~$ sudo apt-get install golang-stable         fail c) complie from source code        

如何更换 Ubuntu 18.04 LTS 的 GDM 登录界面背景

Ubuntu 18.04 LTS 桌面系统在登录.锁屏和解锁状态下,我们会看到一个纯紫色的背景.这篇短文将会告诉你如何更换 Ubuntu 18.04 LTS 的 GDM 登录界面的背景. Ubuntu 18.04 LTS 桌面系统在登录.锁屏和解锁状态下,我们会看到一个纯紫色的背景.它是GDM(GNOME 显示管理器)从 ubuntu 17.04 版本开始使用的默认背景.有一些人可能会不喜欢这个纯色的背景,想换一个酷一点.更吸睛的!如果是这样,你找对地方了. 更换 Ubuntu 的登录界面背景

How To Install Docker On Ubuntu 18.04

Docker is an increasingly popular software package that creates a container for application development. Developing in Docker speeds up applications, as it shares the kernel and other resources, instead of requiring dedicated resources. There are two

Ubuntu 18.04 LTS安装Samba服务及配置

局域网下使用samba服务在Linux系统与Windows系统直接共享文件是一项很方便的操作.以Ubuntu为例配置samba服务,Linux服务器的版本是Ubuntu 18.04.1 LTS. 在终端中执行下列指令:cat /etc/issue查看当前正在运行的 Ubuntu 的版本号. 以下是我的安装配置步骤: (1)更新当前软件. sudo apt-get upgrade sudo apt-get update sudo apt-get dist-upgrade (2)安装samba服务器

Install Mariadb in Ubuntu 16.04 LTS

MariaDB官网提供了repository https://downloads.mariadb.org/mariadb/repositories/#mirror=tuna 在这里可以查询到各类系统的安装方法,这里仅对Ubuntu 16.04 LTS讲解. add key sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 add sources sudo sh -c

Ubuntu 18.04 LTS IP 地址设置

和之前的版本不太一样, Ubuntu 18.04 的 ip地址设置是用netplan管理的 配置文件在: /etc/netplan/50-cloud-init.yaml 示例文件如下: # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network

Install Atom in Ubuntu 16.04 LTS

Atom是一款现代化,平易近人的文本编辑器,它可以嵌入到内核中 - 这个工具可以自定义做任何事情,但也可以有效地使用,而无需触摸配置文件.这里讲解它在Ubuntu 16.04 Desktop LTS环境中基于ppa模式的的安装过程. add ppa apt add-repository ppa:webupd8team/atom update apt update install sudo apt-get install atom 原文地址:http://blog.51cto.com/qwfys2

[系统软件]Ubuntu 18.04 LTS 安装 搜狗输入法,谷歌拼音

1. 讲什么 本文主要讲述在Ubuntu18.04 LTS版本中安装搜狗输入法.谷歌拼音输入法的过程. 2. 为什么讲 1. Ubuntu电脑自带Ibus输入法+拼音/五笔,但是用了一段时间之后发现经常会出现输入不了中文的现象,解决办法是去清空ibus的配置文件,但是这样会把自己每天使用电脑变得更加麻烦 2. 同时网上对于Ubuntu中某些特定的软件,例如sublime等不能输入中文的解决办法都是提出基于fcitx的解决方案 3. sougou输入法基于输入法市场是比较成熟的,模拟输入.检测目标

将 Ubuntu 16.04 LTS 升级到 Ubuntu 18.04 LTS

抄自http://www.cnblogs.com/it-tsz/p/9858447.html 工具/原料 Ubuntu 16.04LTS 方法/步骤 1 更新Ubuntu 16.04 在升级之前, 您应该先更新当前的16.04. 建议升级之前更新/升级所有已安装的软件包. 运行以下命令: sudo apt update && sudo apt dist-upgrade && sudo apt autoremove 2 安装Ubuntu update manager 更新完