javajava-8raspberry-piraspbian

Unable to install Java 8 on raspbian lite


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.


Solution

  • 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