How to install openjdk-8-jdk on Debian 10 (Buster)?

耗尽温柔 提交于 2020-04-07 17:10:15

问题


It seems Debian does not support openjdk-8-jdk anymore due to a security issue. What is the easiest way to install openjdk-8-jdk for Debian 10 (Buster)?


回答1:


alternatively, you can use adoptopenjdk repository.

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

https://adoptopenjdk.net/installation.html




回答2:


I found this way. Add in your sources.list:

sudo vim /etc/apt/sources.list

The following repo:

deb http://ftp.us.debian.org/debian sid main

Then:

sudo apt-get update

Last:

sudo apt-get install openjdk-8-jdk

Additional steps:

sudo update-alternatives --config java

Choose your java version.

https://packages.debian.org/sid/openjdk-8-jdk




回答3:


You can search the Debian packages site and find out the openjdk-8-jdk package for Debian 10 is only available from unstable (sid) repository currently.

At first it is good to check and save current system-wide symbolic links for already installed Java SDK/JRE packages if any:

ls -la /etc/alternatives | grep java > previous-java-alternatives.txt

Then check is this package can be installed with current configuration:

apt-cache policy openjdk-8-jdk

If no then you need to add unstable repository to the sources list. The negative output may imply that you prefer to use stable repositories and usually it isn't appropriate for you to update all other software from unstable repositories. So before adding unstable repository to the sources list make sure APT::Default-Release configuration option is set to "stable":

grep -r Default-Release /etc/apt/

If no (as by default) then set it as recommended in that answer by creating this file:

/etc/apt/apt.conf.d/99defaultrelease

APT::Default-Release "stable";

Now you're ready to add the unstable repository to the sources list. Before I prefer to check what mirror was selected by me when system was installed. Just look to main sources list:

cat /etc/apt/sources.list

In my case the output shows that mirror.yandex.ru server is used as system source. So I use the same for unstables and add this file:

/etc/apt/sources.list.d/91-debian-unstable.list

deb http://mirror.yandex.ru/debian/ unstable main
deb-src http://mirror.yandex.ru/debian/ unstable main

(I also have 90-debian-testing.list file for the testing repo.)

Then update package lists:

apt update

And check you system wont update from unstable sources:

apt list --upgradable

And recheck is required package can be installed:

apt-cache policy openjdk-8-jdk

Do install the package:

apt install openjdk-8-jdk

Look at new symbolic links:

ls -la /etc/alternatives | grep java-8

Just waste few seconds on them (or continue with man 1 update-alternatives).




回答4:


I needed to install a 32-bit version but this wasn't available at adoptopenjdk far as I could see. I tracked down a copy of a binary at java.com i their downloads area:

jre-8u241-linux-i586.tar.gz

All I needed was the JRE (rather than a JDK, but the process should be the same for either) and since it was also for a personal use only, the Oracle binary was OK (they have limitations in this regard).

I downloaded the binary and placed it in the home folder (~/) of the user that needed to run it and then unzipped it like so:

mkdir ~/java && cd ~/java && tar -xf jre-8u241-linux-i586.tar.gz

Then added the location to the path of the user that would run the Java application by appending this line to ~/.profile:

export PATH=$PATH:/home/youruserid/java/jre1.8.0_241/bin

This worked fine for my case but there are no doubt better ways to install a binary. For example so it is available for all Unix users rather than just one.




回答5:


I was migrating from Jessie to Buster, and found that not-so-old, legacy code would not compile and run on JDK11.

I managed to copy all java8 folders from my Jessie distribution, reworked the links, and set that as a new JDK on Eclipse. That works so far.




回答6:


the easiest way I have found to download java 8 on debian buster is to use the command su apt-get install openjdk-8-jdk



来源:https://stackoverflow.com/questions/57031649/how-to-install-openjdk-8-jdk-on-debian-10-buster

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!