You are on Debian 10 (buster), but the link you showed is for Debian 9 (stretch).

OpenJDK is on version 11 for Buster and OpenJDK 8 is not available.

https://packages.debian.org/buster/openjdk-11-jdk

If you need this, use a docker image based on Stretch.

Answer from Sven on serverfault.com
Top answer
1 of 15
149

UPDATE: installation without root privileges below


I advise you to not install packages manually on ubuntu system if there is already a (semi-official) repository able to solve your problem. Further, use Oracle JDK for development, just to avoid (very sporadic) compatibility issues (i've tried many years ago, it's surely better now).

Add the webupd8 repo to your system:

Copysudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Install your preferred version of jdk (versions from java-6 to java-9 available):

Copysudo apt-get install oracle-java8-installer

You can also install multiple version of jdk, mixing openjdk and oracle versions. Then you can use the command update-java-alternatives to switch between installed version:

Copy# list available jdk
update-java-alternatives --list

# use jdk7
sudo update-java-alternatives --set java-7-oracle

# use jdk8
sudo update-java-alternatives --set java-8-oracle

Requirements

If you get add-apt-repository: command not found be sure to have software-properties-common installed:

Copysudo apt-get install software-properties-common

If you're using an older version Ubuntu:

Copysudo apt-get install python-software-properties

JDK installation without root privileges

If you haven't administrator rights on your target machine your simplest bet is to use sdkman to install the zulu certified openjdk:

Copycurl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java

NOTE: sdkman allow to install also the official Oracle JDK, although it's not a the default option. View available versions with:

Copysdk ls java

Install the chosen version with:

Copysdk install java <version>

For example:

Copysdk install java 9.0.1-oracle

Glossary of commands

  • sudo <command> [command_arguments]: execute a command with the superuser privilege.

  • add-apt-repository <PPA_id>: Ubuntu (just like every Debian derivatives and generally speaking every Linux distribution) has a main repository of packages that handle things like package dependencies and updating. In Ubuntu is possible to extend the main repository using a PPA (Personal Package Archive) that usually contains packages not available in the system (just like oracle jdk) or updated versions of available ones (example: LibreOffice 5 in LTS is available only through this PPA).

  • apt-get [install|update|upgrade|purge|...]: it's "the" command-line package handler used to manipulate the state of every repository on the system (installing / updating / upgrading can be viewed as an alteration of the repository current state).

In our case: with the command sudo add-apt-repository ppa:webupd8team/java we inform the system that the next repository update must retrieve packages information also from webupd8 repo.

With sudo apt-get update we actually update the system repository (all this operations requires superuser privileges, so we prepend sudo to the commands).

sudo apt-get install oracle-java8-installer

  • update-java-alternatives (a specific java version of update-alternatives): in Ubuntu several packages provides the same functionality (browse the internet, compile mails, edit a text file or provides java/javac executables...). To allows the system to choose the user favourites tool given a specific task a mechanism using symlinks under /etc/alternatives/ is used. Try to update the jdk as indicated above (switch between java 7 and java 8) and view how change the output of this command:

    ls -l /etc/alternatives/java*

In our case: sudo update-java-alternatives --set java-8-oracle update symlinks under /etc/alternatives to point to java-8-oracle executables.

Extras:

  • man <command>: start using man to read a really well written and detailed help on (almost) every shell command and its options (every command i mention in this little answer has a man page, try man update-java-alternatives).

  • apt-cache search <search_key>: query the APT cache to search for a package related with the search_key provided (can be the package name or some word in package description).

  • apt-cache show <package>: provides APT information for a specific package (package version, installed or not, description).

2 of 15
133

As you can see I only have java 1.7 installed (on a Ubuntu 14.04 machine).

Copyupdate-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64

To install Java 8, I did,

Copysudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

Afterwards, now I have java 7 and 8,

Copyupdate-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1069 /usr/lib/jvm/java-1.8.0-openjdk-amd64

BONUS ADDED (how to switch between different versions)

  • run the follwing command from the terminal:

sudo update-alternatives --config java

CopyThere are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode

Press enter to keep the current choice[*], or type selection number:

As you can see I'm running open jdk 8. To switch to to jdk 7, press 1 and hit the Enter key. Do the same for javac as well with, sudo update-alternatives --config javac.

Check versions to confirm the change: java -version and javac -version.

Discussions

Trouble installing OpenJDK 8
It appears that the package you want is not included in available packages. First, do this: $ apt list | grep -i openjdk If the package you want is not listed, then it cannot be installed until the right repository is included in your configuration: $ sudo add-apt-repository ppa:openjdk-r/ppa $ sudo apt-get update Now try again. More on reddit.com
🌐 r/linuxquestions
10
3
July 16, 2019
apt - How can I install Java 8 on Debian 11 (Bullseye)? - Unix & Linux Stack Exchange
This answer explains why it was removed. I'm not interested in the reason, instead, I need to install it. This VM is solely dedicated to my Java app, so I'm not really interested in using a contain... More on unix.stackexchange.com
🌐 unix.stackexchange.com
Why can't I get Java 8?
Why can't I get Java 8? Why can't you get Windows 98? Debian Stable (old in the tooth at this point) is on openjdk 11. More on reddit.com
🌐 r/linuxquestions
13
0
August 3, 2021
Trying to install Java 8 - Unable to locate package openjdk-8-jdk
I am trying to install javasdk8 in my cog file for using spark nlp from within the docker. it fails with the following error ` => ERROR [stage-0 4/13] RUN --mount=type=cache,target=/var/cache/ap... More on github.com
🌐 github.com
5
May 14, 2022
🌐
Reddit
reddit.com › r/linuxquestions › trouble installing openjdk 8
r/linuxquestions on Reddit: Trouble installing OpenJDK 8
July 16, 2019 -

I'm running Debian 9.9 Stretch and am having problems installing OpenJDK 8. I've been Googling stuff for a while but I'm getting nowhere.

Upon entering:

sudo apt-get install openjdk-8-jdk-headless    

The output is:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package openjdk-8-jdk-headless is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'openjdk-8-jdk-headless' has no installation candidate

I'd appreciate any help or tips on where to look to resolve this.

edit - Problem solved. Finding older versions of OpenJDK on repositories is hard work, if you want one, just download and install it yourself. As for the reason I posted this, the Minecraft server works fine with OpenJDK 11.

Top answer
1 of 3
6

Copies of past Debian packages are available at http://snapshot.debian.org/

You can search there for openjdk-8. The last available version is 8u322-b06-1~deb9u1, logged at http://snapshot.debian.org/package/openjdk-8/8u322-b06-1%7Edeb9u1/ You can download the binary packages (.deb) for your architecture and install with sudo dpkg -i *.deb.

Whether it works or not depends on the library versions that it was built against. 8u312-b07-1 (and other older versions) is also available.

Alternatively you can access the Debian tracking page for the package at https://tracker.debian.org/pkg/openjdk-8. openjdk-8 is still listed there as available for unstable (as version 8u312-b07-1). If you click on the links for the binary packages, they will lead you to download links for the deb packages.

snapshot.debian.org is arguably simpler for ad-hoc downloading since it has the deb files in one place (the debian package repository finds them in http://ftp.us.debian.org/debian/pool/main/o/openjdk-8/ or its mirror sites)

snapshot.debian.org also suggests instructions for configuring sources.list. But if the package is not likely to be updated often then it might be simpler to just download the deb files manually.

2 of 3
5

Since Oracle changed Java licensing, Bellsoft (not affiliated) has done a great job at providing openJDK installers. They just work, and you can choose between:

  • JDK / JRE
  • Java 8 / 11 / 17 / 19
  • With or without JavaFX
  • Windows / Debian / Redhat / Alpine / Solaris / macOs installer

You'll surely find the correct installer at https://bell-sw.com/pages/downloads/#/java-8-lts.

You can install multiple Java versions if you wish. If you need to juggle between versions, you might be interested in this answer.

🌐
Reddit
reddit.com › r/linuxquestions › why can't i get java 8?
r/linuxquestions on Reddit: Why can't I get Java 8?
August 3, 2021 -

I'm trying to get Java 8 on my Raspberry Pi 4 (running the beta 64 bit OS), so that I can get my Minecraft server working. Before I changed to the 64 bit OS, it was working fine. But now, when I type:

sudo apk install openjdk-8-jdk

it spits this back at me:

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

I feel like I've tried EVERYTHING, and this is making my brain melt with frustration.

It's probably worth mentioning that I know next to nothing about Linux. Hell, I don't even know if this is the right sub!

Find elsewhere
🌐
Untitled Publication
8thesource.hashnode.dev › unable-to-locate-package-openjdk-8-jre
Unable to Locate Package openjdk 8 jre - Untitled Publication
July 28, 2022 - Even though it should be, the OpenJDK package is not always found in the repository. It's just due to a compatibility issue. It will function great if you obtain the suitable OpenJDK from the official repository.
🌐
GitHub
github.com › replicate › cog › issues › 615
Trying to install Java 8 - Unable to locate package openjdk-8-jdk · Issue #615 · replicate/cog
May 14, 2022 - [stage-0 4/13] RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy zip unzip openjdk-8-jdk && rm -rf /var/lib/apt/lists/*: #10 3.517 E: Unable to locate package openjdk-8-jdk ·
Author   replicate
🌐
Its Linux FOSS
itslinuxfoss.com › home › fix: unable to locate package openjdk 8 jdk
Fix: unable to locate package openjdk 8 jdk – Its Linux FOSS
December 8, 2022 - The error “unable to locate package openjdk 8 jdk” occurs if the OpenJDK-8 is installed without adding PPA. To solve this, add the appropriate PPA repository and update the system followed by the command “sudo apt install openjdk-8-jdk”. ...
🌐
Reddit
reddit.com › r/debian › where is java 8? (debian 12)
r/debian on Reddit: Where is java 8? (Debian 12)
November 15, 2023 -

Hello all.

I just want to ask why there is no package for jdk 1.8 forDebian 12? I've seen one for Sid the open-jdk-8.

Why is it so?

Can I change my sources.list for sid, install open-jdk-8 and then revert sources back to bookworm?

Thank you for your responses.

Top answer
1 of 15
16
I just want to ask why there is no package for jdk 1.8 forDebian 12? Debian only maintains a single JDK per release, because of the work it entails. (Also, it probably doesn't help that OpenJDK 8 was originally supposed to be EOL by now .) Can I change my sources.list for sid, install open-jdk-8 and then revert sources back to bookworm? I would avoid doing this. If you don't run in to any problems with mixing releases, that still leaves you with no way of getting security updates for Java. If you definitely need an alternative version of Java, third-party repositories are probably your best bet. I don't personally know what people currently prefer to use, but the Zula builds of OpenJDK are offered by extrepo , so that would be an easy thing to try first.
2 of 15
9
why there is no package for jdk 1.8 for Debian 12? Because openjdk-8 was superseded by openjdk-11, which in turn was superseded by openjdk-14, which in turn was superseded by openjdk-17, which is the default java version in Debian 12. Can I change my sources.list for sid, install open-jdk-8 and then revert sources back to bookworm? You probably can do that, but then you will get a lot of other packages from sid, and your system will become a "frankendebian". Not recommended. In general, installing packages from testing or unstable on a system running stable is not a good idea. Whenever I needed an old java version I usually take it from a previous release (not from testing or unstable). That usually works. But openjdk-8 is too old and it's not even in Debian 11. The real question here would be: Why are you still using java 8?
🌐
Brainly
brainly.com › computers and technology › high school › fix the error: unable to locate package openjdk-8-jdk
[FREE] Fix the error: unable to locate package openjdk-8-jdk - brainly.com
November 19, 2023 - To fix the 'unable to locate package openjdk-8-jdk' error, update your package list using 'sudo apt-get update' and ensure the universe repository is enabled. If these steps do not resolve the issue, consider adding a PPA or downloading the ...
🌐
LinuxQuestions.org
linuxquestions.org › questions › antix-mx-linux-127 › openjdk-8-jdk-unable-to-locate-package-4175674189
openjdk-8-jdk unable to locate package
April 29, 2020 - I want to try out the prog portfolio performance, to get it runnung I need java version 8. I tried to install it but I get the following error code
Top answer
1 of 3
1

openjdk-8 is available in my default Jessie/stable install - just need to apt-get install it (openjdk-8-jdk and whatever else you want/need that it recommends or depends on)

Of course, it MAY depend on your /etc/apt/sources.list file including the contrib and non-free repositories

/etc/apt/sources.list should look something like

deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free
2 of 3
0

The first thing is always see the Debian PTS to have an idea of what options are available to you. For instance, if I go to -

https://tracker.debian.org/pkg/openjdk-8

On the left-hand side you have something called versions - can you see it, it shows -

  stable-bpo: 8u121-b13-1~bpo8+1
     testing: 8u121-b13-3
    unstable: 8u121-b13-4

Now stable-bpo means it is in backports. the backports page describes its function excellently, see https://backports.debian.org/

So you need to add as shared by @Reto as well the backports address to the list of packages that you already have -

deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free

Now update the index, it should say something like this at the very end -

Reading package lists... Done
Building dependency tree       
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.

Don't see the number of packages that can be upgraded as that's a function of how many packages I have, how often I update packages etc. If the four lines are similar to above, that means the index updation went without a hitch, no errors.

Once that is done you could simply do -

$ aptitude search openjdk-8

to get a listing of how many different openjdk-8 packages are listed or not. For instance I'm on testing and there are quite a few here. We also have openjdk-9 as well.

Once you get it , just install as you were trying to install before -

$ sudo aptitude install openjdk-8 

and let aptitude handle all the dependancy resolution. If you still have issues, let us know here.

🌐
GitHub
github.com › WhitewaterFoundry › Pengwin › issues › 448
Cannot install openjdk-8-jre and openjdk-8-jdk · Issue #448 · WhitewaterFoundry/Pengwin
April 30, 2019 - $ apt-get install openjdk-8-jre openjdk-8-jdk -y Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package openjdk-8-jre E: Unable to locate package openjdk-8-jdk
Author   WhitewaterFoundry
🌐
Google Support
support.google.com › chromebook › thread › 52926102 › errors-while-installing-openjdk-8
Errors while installing OpenJDK 8 - Chromebook Community
Skip to main content · Chromebook Help · Sign in · Google Help · Help Center · Community · Chromebook · Terms of Service · Submit feedback · Send feedback on