Java 如何在 Debian 10 (Buster) 上安装 openjdk-8-jdk?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/57031649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install openjdk-8-jdk on Debian 10 (Buster)?
提问by Graham Lee
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)?
由于安全问题,Debian 似乎不再支持 openjdk-8-jdk。为 Debian 10 (Buster) 安装 openjdk-8-jdk 的最简单方法是什么?
回答by Alexander Bravo
I found this way. Add in your sources.list
:
我找到了这个方法。添加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.
选择您的 Java 版本。
回答by oshatrk
You can search the Debian packages siteand find out the openjdk-8-jdk
package for Debian 10 is only available from unstable (sid) repository currently.
您可以搜索Debian 软件包站点,并发现openjdk-8-jdk
Debian 10的软件包目前只能从不稳定 (sid) 存储库中获得。
At first it is good to check and save current system-wide symbolic links for already installed Java SDK/JRE packages if any:
首先,最好检查并保存已安装的 Java SDK/JRE 包的当前系统范围的符号链接(如果有):
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"
:
如果没有,那么您需要将不稳定的存储库添加到源列表中。负输出可能意味着您更喜欢使用稳定的存储库,并且通常不适合您从不稳定的存储库更新所有其他软件。因此,在将不稳定的存储库添加到源列表之前,请确保APT::Default-Release
配置选项设置为"stable"
:
grep -r Default-Release /etc/apt/
If no (as by default) then set it as recommended in that answerby creating this file:
如果没有(默认情况下),则通过创建此文件按照该答案中的建议进行设置:
/etc/apt/apt.conf.d/99defaultrelease
/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:
在我的情况下,输出显示mirror.yandex.ru
服务器用作系统源。所以我对不稳定使用相同的并添加这个文件:
/etc/apt/sources.list.d/91-debian-unstable.list
/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.)
(我也有90-debian-testing.list
测试仓库的文件。)
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
).
只需在它们上浪费几秒钟(或继续使用man 1 update-alternatives
)。
回答by Ahrnov
I was migrating from Jessie to Buster, and found that not-so-old, legacy code would not compile and run on JDK11.
我从 Jessie 迁移到 Buster,发现不太老的遗留代码无法在 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.
我设法从我的 Jessie 发行版中复制了所有 java8 文件夹,重新设计了链接,并将其设置为 Eclipse 上的新 JDK。到目前为止,这是有效的。
回答by summiner12
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
我发现在 debian buster 上下载 java 8 的最简单方法是使用命令 su apt-get install openjdk-8-jdk
回答by Nizarazu
alternatively, you can use adoptopenjdk repository.
或者,您可以使用 Adoptopenjdk 存储库。
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
回答by Moika Turns
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:
我需要安装一个 32 位版本,但就我所见,adaptopenjdk 不提供此版本。我在 java.com 的下载区找到了一份二进制文件:
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).
我所需要的只是 JRE(而不是 JDK,但两者的过程应该相同)并且由于它也仅供个人使用,因此 Oracle 二进制文件是可以的(它们在这方面有限制)。
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:
然后通过将此行附加到 ~/.profile 将位置添加到将运行 Java 应用程序的用户的路径:
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.
这对我的情况很好,但毫无疑问有更好的方法来安装二进制文件。例如,它适用于所有 Unix 用户,而不仅仅是一个用户。
回答by Hirurg103
Package mirror search steps:
包镜像搜索步骤:
In the Search package directoriessearch for openjdk-8-jdk. You can see two results:
- stretch (oldstable)(java): OpenJDK Development Kit (JDK)
- sid (unstable)(java): OpenJDK Development Kit (JDK)
Choose stretch repository
- Scroll to the Download openjdk-8-jdksection and choose your architecture. For example amd64
Now you can see mirrors list and instructions how to install the package via apt:
You should be able to use any of the listed mirrors by adding a line to your /etc/apt/sources.list like this:
deb http://security.debian.org/debian-securitystretch/updates main
在搜索包目录中搜索openjdk-8-jdk。您可以看到两个结果:
- 拉伸(oldstable)(java):OpenJDK开发工具包(JDK)
- sid (unstable)(java): OpenJDK Development Kit (JDK)
选择拉伸存储库
- 滚动到下载 openjdk-8-jdk部分并选择您的架构。例如amd64
现在你可以看到镜像列表和如何通过 apt 安装包的说明:
您应该能够通过在 /etc/apt/sources.list 中添加一行来使用任何列出的镜像,如下所示:
deb http://security.debian.org/debian-securitystretch/updates main
Installation steps:
安装步骤:
Install software source manager
apt-get update apt-get install software-properties-common
Add mirror with openjdk-8-jdk
apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main' apt-get update
Install openjdk 8
apt-get install openjdk-8-jdk
安装软件源管理器
apt-get update apt-get install software-properties-common
使用 openjdk-8-jdk 添加镜像
apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main' apt-get update
安装 openjdk 8
apt-get install openjdk-8-jdk
Note: You can use steps above to find an official Debian mirror with any other package you want to install
注意:您可以使用上述步骤查找包含要安装的任何其他软件包的官方 Debian 镜像