这个星期五,当我运行时,我发现有 2 个软件包由于某种原因被保留了下来apt-get upgrade
,所以很自然地,我做了任何没有经验的系统管理员都会做的事情,卸载了这些软件包,希望我可以简单地重新安装它们,问题就会得到解决。
我不知道,我只是让情况变得更糟了。当我尝试重新安装时openjdk-8-jre-headless
,我得到了这个:
$ apt-get install openjdk-8-jre-headless
Reading package lists... Done
Building dependency tree
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:
openjdk-8-jre-headless : Depends: ca-certificates-java but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我尝试手动升级上述软件包,但无济于事。
$ apt-get upgrade ca-certificates-java
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... ca-certificates-java is already the newest version.
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
环顾四周,我没有看到任何地方提到针对这个确切错误的解决方案。
我在服务器上使用了 ElasticSearch,我重启了服务器,但我本该预料到此时它不会启动。所以现在我没有 Java,我的用户也没有搜索功能。发生了什么事?我该如何解决这个问题?
答案1
这对我有用:
apt install -t jessie-backports openjdk-8-jre-headless ca-certificates-java
答案2
首先您需要添加
jessie-backports
repo。echo "deb http://http.debian.net/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
安装命令
sudo apt-get update sudo apt-get install -t jessie-backports openjdk-8-jre-headless
切换到新的 Java
sudo /usr/sbin/update-java-alternatives -s java-1.8.0-openjdk-amd64
参考: https://github.com/OpenTreeOfLife/germinator/wiki/Debian-upgrade-notes:-jessie-and-openjdk-8
答案3
答案4
这对我有用
apt-get install software-properties-common
add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
apt-get update
apt-get install oracle-java8-installer