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.comYou 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.
Apparently Debian 10 alias Buster only provides openjdk 11 packages.
In my case this meant using debian 9 alias stretch instead. I must admit it wasn't very clever using latest as a version in the first place.
before:
FROM debian:latest
after:
FROM debian:stretch
Debian stretch is a LTS version supported until 06.2022
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, tryman 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).
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 javaCopyThere 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.
Trouble installing OpenJDK 8
apt - How can I install Java 8 on Debian 11 (Bullseye)? - Unix & Linux Stack Exchange
Why can't I get Java 8?
Trying to install Java 8 - Unable to locate package openjdk-8-jdk
OpenJDK8 is not included in Ubuntu 14.04 repositories.
You can install Openjdk8 to Ubuntu 14.04 from a PPA this way:
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jre
I have done the following in the .profile in my home directory.
JAVA_HOME=/opt/jdk1.7.0_79;export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH
once this was added, just log out and login. This will over ride the path to include jdk1.7.0_79 first. You need to use java 8 folder in this case. eg. if you installed java in /downloads/javajre then add the following in the .profile file of your home directory
JAVA_HOME=/downloads/javajre;export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH
Log out and login. This should set your java -version to java 8.
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.
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.
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.
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!
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.
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
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.
when i try to download java 8 it says
┌──(root💀kali)-[~]
└─# sudo apt-get install openjdk-8-jdk
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package openjdk-8-jdk
The answer over at SO is nicer:
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot
I've managed to solve it by manually downloading the packages with wget:
RUN wget http://security.debian.org/debian-security/pool/updates/main/o/openjdk-8/openjdk-8-jre-headless_8u212-b03-2~deb9u1_amd64.deb \
&& wget http://security.debian.org/debian-security/pool/updates/main/o/openjdk-8/openjdk-8-jre_8u212-b03-2~deb9u1_amd64.deb \
&& wget http://security.debian.org/debian-security/pool/updates/main/o/openjdk-8/openjdk-8-jdk-headless_8u212-b03-2~deb9u1_amd64.deb \
&& wget http://security.debian.org/debian-security/pool/updates/main/o/openjdk-8/openjdk-8-jdk_8u212-b03-2~deb9u1_amd64.deb
and then install it using the dkpg with the -i --force-all options to install all the required dependencies:
RUN dpkg -i --force-all openjdk-8-jre-headless_8u212-b03-2~deb9u1_amd64.deb openjdk-8-jre_8u212-b03-2~deb9u1_amd64.deb openjdk-8-jdk-headless_8u212-b03-2~deb9u1_amd64.deb openjdk-8-jdk_8u212-b03-2~deb9u1_amd64.deb