问题:Ubuntu系统执行apt install openjdk-8-jdk
安装jdk8报错
root@2b6d781ebc36:/# apt install openjdk-8-jdk
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
debianutils : Breaks: x11-common (< 1:7.7+23~) but 1:7.7+19ubuntu14 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
解决:
方案一:修改源
#备份文件
cp /etc/apt/sources.list /etc/apt/sources.list-$(date +%Y%m%d)
#修改源
sed -i 's/focal/jammy/g' /etc/apt/sources.list
sed -i 's/focal/jammy/g' /etc/apt/sources.list.d/*.list
apt-get update
#重新执行安装命令安装成功
apt install openjdk-11-jre
方案二:aptitude
方式解除依赖并安装
#如果没有"aptitude"这个命令,直接安装
sudo apt-get install aptitude
# 通过aptitude安装包
sudo aptitude install <包名>
是否接受该解决方案?[Y/n/q?]
#输入 Y
#随后开始安装
例如: 通过aptitude 安装openjdk-8
sudo apt-get install aptitude
sudo aptitude install openjdk-8