1

I am attempting to install OpenJDK on my headless server running Ubuntu 20.04. I've done this before on older versions of Ubuntu, but as it had been a while since then, I couldn't remember the package name. I put in the java command so that I could find the correct package name, and I received this:

Command 'java' not found, but can be installed with:

sudo apt install default-jre              # version 2:1.11-72, or
sudo apt install openjdk-11-jre-headless  # version 11.0.7+10-3ubuntu1
sudo apt install openjdk-8-jre-headless   # version 8u252-b09-1ubuntu1

I wanted OpenJDK 8, so I put in sudo apt install openjdk-8-jre-headless and hit enter, expecting it to be installed. Instead, I received this:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package openjdk-8-headless

I don't understand why the package can't be located. I've done everything I can think of, and I can't seem to find anyone else having this problem, so any help would be greatly appreciated. Thanks for your time!

Batchicken
  • 31
  • 1
  • 2
  • 2
    Did you do apt update before install? And universe enabled? – Alvin Liang Apr 30 '20 at 03:17
  • Alvin Liang is correct; https://packages.ubuntu.com/search?suite=focal&searchon=names&keywords=openjdk shows it's there & available once 'universe' is enabled (it's community sourced packages so is not enabled by default on Ubuntu; Ubuntu only comes with 5 year supported packages until you enable other package streams that usually have shorter lives). https://help.ubuntu.com/community/Repositories/Ubuntu – guiverc Apr 30 '20 at 03:59
  • 2
    Does this answer your question? [How do I enable the "Universe" repository?](https://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository) – user535733 Apr 30 '20 at 04:07
  • I actually already have the Universe repository enabled. It still can't find the package, which is why I'm stumped. – Batchicken Apr 30 '20 at 11:03
  • 1
    Does this answer your question? [How do I install Java?](https://askubuntu.com/questions/48468/how-do-i-install-java) – Kulfy Jul 31 '20 at 15:19

1 Answers1

5

You made a typo: the error message says that it can't find openjdk-8-headless.

But the correct package name is openjdk-8-jre-headless. It is available and installs without any issues on 20.04.

Pilot6
  • 88,764
  • 91
  • 205
  • 313