1

I recently installed Ubuntu 18.04 LTS in dual boot with Windows 10. I tried to install the default-jdk for java in Ubuntu 18.04 LTS but fails to install giving "failed to fetch"/"unable to fetch" errors as given in output below -

:~$ 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?

I am new to Ubuntu and bash terminal, so detailed explanation and step-by-step guide to solve will be appreciated!!

Mayank Lad
  • 11
  • 1
  • 2
  • Didn't work @karel – Mayank Lad Jan 28 '20 at 15:38
  • Welcome to AskUbuntu when the 18.04 LTS was released, the JDK 11 was not available, so you can install JDK 10 instead or use ppa to force install JDK 11. "sudo apt install openjdk-11-jdk" you get version 10. Or JavaRuntimeEnvironment if you don't develop Java. https://askubuntu.com/questions/48468/how-do-i-install-java?noredirect=1&lq=1 – Sadaharu Wakisaka Jan 29 '20 at 03:09
  • Does this answer your question? [Trouble downloading packages list due to a "Hash sum mismatch" error](https://askubuntu.com/questions/41605/trouble-downloading-packages-list-due-to-a-hash-sum-mismatch-error) – karel Jun 06 '20 at 02:58

1 Answers1

1

Use the adopt version, it is the same thing (but I guess it has better support and is newer, not quite sure).

Import the official AdoptOpenJDK GPG key

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

Import the AdoptOpenJDK DEB repository by running the following command:

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

If you get a "command not found" error, try running:

apt-get install -y software-properties-common

Then repeat the first command.

Refresh your package list with apt-get update and then install your chosen AdoptOpenJDK package. For example, to install OpenJDK 11 with the HotSpot VM, run:

apt-get install adoptopenjdk-11-hotspot

taken from this page

s1mmel
  • 1,974
  • 13
  • 19