无法通过 apt-get install 在 Ubuntu 18.04 LTS 上安装默认 jdk 包

无法通过 apt-get install 在 Ubuntu 18.04 LTS 上安装默认 jdk 包

我最近在 Windows 10 的双启动中安装了 Ubuntu 18.04 LTS。我尝试在 Ubuntu 18.04 LTS 中安装 Java 的默认 jdk,但安装失败,并出现“无法获取”/“无法获取”错误,如下面的输出所示 -

:~$ sudo apt-get clean all

:~$ sudo apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease             
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease           
Hit:4 http://packages.microsoft.com/repos/vscode stable InRelease              
Hit:5 http://archive.canonical.com/ubuntu bionic InRelease                     
Hit:6 http://security.ubuntu.com/ubuntu bionic-security InRelease        
Reading package lists... Done                      

:~$ sudo apt-get install default-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java default-jdk-headless default-jre default-jre-headless
  fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni
  libgif7 libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libx11-doc
  libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk
  openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless
  x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
  libice-doc libsm-doc libxcb-doc libxt-doc openjdk-11-demo openjdk-11-source
  visualvm fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  | fonts-wqy-zenhei
The following NEW packages will be installed:
  ca-certificates-java default-jdk default-jdk-headless default-jre
  default-jre-headless fonts-dejavu-extra java-common libatk-wrapper-java
  libatk-wrapper-java-jni libgif7 libice-dev libpthread-stubs0-dev libsm-dev
  libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev
  openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre
  openjdk-11-jre-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools
  xtrans-dev
0 upgraded, 27 newly installed, 0 to remove and 4 not upgraded.
Need to get 238 MB of archives.
After this operation, 400 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 java-common all 0.68ubuntu1~18.04.1 [14.5 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jre-headless amd64 11.0.5+10-0ubuntu1.1~18.04 [37.5 MB]
Err:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jre-headless amd64 11.0.5+10-0ubuntu1.1~18.04
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:59a828f875298c31f8b22641f4344de8e2005c3c43c86e2f36ca85887a6afc52
   - SHA1:a0de605a483ec0320487ca8f84ef4fe7edffe9f6 [weak]
   - MD5Sum:81ace447efacc92a7b61a8da1f3bb0ef [weak]
   - Filesize:37461556 [weak]
  Hashes of received file:
   - SHA256:da0d6bd3620a8d85210a5e29d369697c98b6443db1bad952474fb10fb0f33fed
   - SHA1:875e858263f4f0e8d8f34f53c49f65d57e089e2a [weak]
   - MD5Sum:f1e324cf7554296ab7c7a41dda531dd7 [weak]
   - Filesize:37461556 [weak]
  Last modification reported: Tue, 17 Dec 2019 19:53:49 +0000
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jre-headless amd64 2:1.11-68ubuntu1~18.04.1 [10.9 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ca-certificates-java all 20180516ubuntu1~18.04.1 [12.2 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgif7 amd64 5.1.4-2ubuntu0.1 [30.9 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jre amd64 11.0.5+10-0ubuntu1.1~18.04 [34.4 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jre amd64 2:1.11-68ubuntu1~18.04.1 [1,076 B]
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jdk-headless amd64 11.0.5+10-0ubuntu1.1~18.04 [192 MB]
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jdk-headless amd64 2:1.11-68ubuntu1~18.04.1 [1,132 B]
Get:10 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jdk amd64 11.0.5+10-0ubuntu1.1~18.04 [2,203 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jdk amd64 2:1.11-68ubuntu1~18.04.1 [1,092 B]
Get:12 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 fonts-dejavu-extra all 2.37-1 [1,953 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libatk-wrapper-java all 0.33.3-20ubuntu0.1 [34.7 kB]
Get:14 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libatk-wrapper-java-jni amd64 0.33.3-20ubuntu0.1 [28.3 kB]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 xorg-sgml-doctools all 1:1.11-1 [12.9 kB]
Get:16 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 x11proto-dev all 2018.4-4 [251 kB]
Get:17 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 x11proto-core-dev all 2018.4-4 [2,620 B]
Get:18 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libice-dev amd64 2:1.0.9-2 [46.8 kB]
Get:19 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libpthread-stubs0-dev amd64 0.3-4 [4,068 B]
Get:20 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libsm-dev amd64 2:1.2.2-1 [16.2 kB]
Get:21 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libxau-dev amd64 1:1.0.8-1 [11.1 kB]
Get:22 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libxdmcp-dev amd64 1:1.1.2-3 [25.1 kB]
Get:23 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 xtrans-dev all 1.3.5-1 [70.5 kB]
Get:24 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libxcb1-dev amd64 1.13-2~ubuntu18.04 [80.0 kB]
Get:25 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libx11-dev amd64 2:1.6.4-3ubuntu0.2 [640 kB]
Get:26 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libx11-doc all 2:1.6.4-3ubuntu0.2 [2,065 kB]
Get:27 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 libxt-dev amd64 1:1.1.5-1 [395 kB]
Fetched 238 MB in 1min 5s (3,681 kB/s)                                         
E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/o/openjdk-lts/openjdk-11-jre-headless_11.0.5+10-0ubuntu1.1~18.04_amd64.deb  Hash Sum mismatch
   Hashes of expected file:
    - SHA256:59a828f875298c31f8b22641f4344de8e2005c3c43c86e2f36ca85887a6afc52
    - SHA1:a0de605a483ec0320487ca8f84ef4fe7edffe9f6 [weak]
    - MD5Sum:81ace447efacc92a7b61a8da1f3bb0ef [weak]
    - Filesize:37461556 [weak]
   Hashes of received file:
    - SHA256:da0d6bd3620a8d85210a5e29d369697c98b6443db1bad952474fb10fb0f33fed
    - SHA1:875e858263f4f0e8d8f34f53c49f65d57e089e2a [weak]
    - MD5Sum:f1e324cf7554296ab7c7a41dda531dd7 [weak]
    - Filesize:37461556 [weak]
   Last modification reported: Tue, 17 Dec 2019 19:53:49 +0000
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

我是 Ubuntu 和 bash 终端的新手,因此如果能提供详细的解释和逐步解决的指南将不胜感激!!

答案1

使用采用的版本,它是同样的东西(但我猜它有更好的支持并且更新,不太确定)。

导入官方 AdoptOpenJDK GPG 密钥

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

通过运行以下命令导入 AdoptOpenJDK DEB 存储库:

sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

如果出现“未找到命令”错误,请尝试运行:

apt-get install -y software-properties-common

然后重复第一个命令。

使用刷新您的软件包列表apt-get update,然后安装您选择的 AdoptOpenJDK 软件包。例如,要使用 HotSpot VM 安装 OpenJDK 11,请运行:

apt-get install adoptopenjdk-11-hotspot

取自于此

相关内容