0

Trying to install Java 8 as I need an older version of Java to run something. I am using a Raspberry Pi 4B 8GB and am very new when it comes to Linux.

I tried running sudo apt install openjdk-8-jdk and when that wouldn't work I tried researching. The only things I could find I either couldn't understand or just wouldn't work. I'm sorry if I didn't give enough information, like I said I am very new to this stuff.

Edit:

When I try to run sudo apt install openjdk-8-jdk, I get the error message:

Unable to locate package openjdk-8-jdk.

This happened after I used sudo apt update and sudo apt upgrade.

I did run sudo apt install default-jdk and it tells me it is already in the newest version but when I try to run sudo update-alternatives --config java, it tells me there is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-arm64/bin/java nothing to configure.

Sorry for not being clear.

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
Dom
  • 3
  • 3

1 Answers1

0

Depending on what you meant by it would not work.

Java resolving to wrong version:
Assuming that Java is still resolving to another version. Then you probably have multiple installed. You can switch using the following command:

update-alternatives --config java

openjkd-8-jdk not available for installation:
Assuming that the package could not be found, you could try run the following command to update the local list of packages. Then try to install it again.

sudo apt update

If it still does not find openjdk-8-jdk after sudo apt update, you might need to add a mirror by adding a line to your /etc/apt/sources. list. Have a look at this thread, maybe it helps. How to install openjdk-8-jdk on Debian 10 (Buster)?

Choose one of the mirrors listed here. https://packages.debian.org/sid/amd64/openjdk-8-jdk/download

Add it to the list of mirrors in your linux installation.

sudo apt-add-repository 'deb http://ftp.de.debian.org/debian sid main'

Update the local list of packages again and try to install it.

sudo apt update --allow-unauthenticated
sudo apt install openjdk-8-jdk 
kahobe
  • 36
  • 4
  • I ran the commands like you said and when running sudo apt update errors showed up E: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disable by default. N: See apt-secure(8) manpage for repository creation and user configuration details. – Dom Aug 29 '23 at 19:32
  • I updated my answer, please note that I also changed the mirror, I forgot to do this previously. – kahobe Aug 29 '23 at 19:42
  • as I said I am new to Linux and am kind of confused about the wording. don't mean to be a bother but it would help if you guided me through adding one of the mirrors – Dom Aug 29 '23 at 19:47
  • Just run the apt-add-repository command again from my answer, then apt update, then apt install. – kahobe Aug 29 '23 at 19:49
  • If this works, you finally will probably have to run the update-alternatives --config java command again. – kahobe Aug 29 '23 at 19:50
  • I reran those commands and the same errors were showing up after sudo apt update --allow-unauthenticated. Is there something new I have to do at this website you linked https://packages.debian.org/sid/amd64/openjdk-8-jdk/download? – Dom Aug 29 '23 at 19:56
  • Maybe go to this file /etc/apt/sources.list and remove the line that contains the mirror (http://security.debian.org/debian-security ) you added previously, this line still being in might cause the error message. – kahobe Aug 29 '23 at 20:00
  • im realizing know that when I hit tab to cd into /etc/apt/sources.list it put me into /etc/apt/sources.list.d but there is no sources.list and the mirror isnt even in the sources.list.d directory – Dom Aug 29 '23 at 20:05
  • It has to be somewhere, please look up where it is located in the distro you are using. – kahobe Aug 29 '23 at 20:09
  • i found sources.list but it says its not a directory but just a file – Dom Aug 29 '23 at 20:15
  • i downloaded the file onto my pc and i found the mirror in the text file is that what i should delete? – Dom Aug 29 '23 at 20:16
  • Yes, it is a file, remove just the one line that contains the mirror mentioned before. – kahobe Aug 29 '23 at 20:19
  • Maybe also dont copy the file to your local pc, but edit it with a text editor like vim or nano. – kahobe Aug 29 '23 at 20:24
  • now it is telling me E: Type 'stretch/updates' is not known on line 9 in source list /etc/apt/sources.list E: The list of sources could not be read. I think that they were related to the mirror should i delete those too? – Dom Aug 29 '23 at 20:31
  • I just removed them but the first error is coming up still E: The repository 'http://security.debian.org/debian-security stretch/updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. – Dom Aug 29 '23 at 20:35
  • Then you did not remove the line containing http://security.debian.org/debian-security – kahobe Aug 29 '23 at 20:41
  • I see it through vim but e212 comes up saying cannot open file for writing and it wont save when i delete security.debian.org/debian-security – Dom Aug 29 '23 at 20:54
  • Finally got it working. deleting the line totally worked I can't thank you enough I've been struggling on this for like two days thanks so much. – Dom Aug 29 '23 at 22:20