无法安装default-jre - 软件包“default-jre”没有安装候选

无法安装default-jre - 软件包“default-jre”没有安装候选

如果我输入

java -version 

我明白了

Command 'java' not found, but can be installed with:

sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless (You will have to enable component called 'universe')

当我尝试时

sudo apt install default-jre

我明白了

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package default-jre is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'default-jre' has no installation candidate

我尝试过 apt-get update 并安装其他的,但是当我尝试 openjdk 时,它说无法找到包...

编辑:

apt policy

输出:

Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic/main i386 Packages
     release v=18.04,o=LP-PPA-mosquitto-dev-mosquitto-ppa,a=bionic,n=bionic,l=mosquitto,c=main,b=i386
     origin ppa.launchpad.net
 500 http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic/main amd64 Packages
     release v=18.04,o=LP-PPA-mosquitto-dev-mosquitto-ppa,a=bionic,n=bionic,l=mosquitto,c=main,b=amd64
     origin ppa.launchpad.net
 500 https://download.mono-project.com/repo/ubuntu stable-bionic/main i386 Packages
     release v=18.04,o=XamarinBionic,a=stable-bionic,n=bionic,l=Xamarin-Stable-Bionic,c=main,b=i386
     origin download.mono-project.com
 500 https://download.mono-project.com/repo/ubuntu stable-bionic/main amd64 Packages
     release v=18.04,o=XamarinBionic,a=stable-bionic,n=bionic,l=Xamarin-Stable-Bionic,c=main,b=amd64
     origin download.mono-project.com
Pinned packages:
head -n -0 /etc/apt/sources.list /etc/apt/sources.list.d/*

输出:

==> /etc/apt/sources.list <==
# deb cdrom:[Ubuntu 16.04.1 LTS _Xenial Xerus_ - Release amd64 (20160719)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb-src http://ca.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

==> /etc/apt/sources.list.d/google-chrome.list <==
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google-chrome.list.distUpgrade <==
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google-chrome.list.save <==
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google.list <==
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # disabled on upgrade to bionic

==> /etc/apt/sources.list.d/google.list.distUpgrade <==
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

==> /etc/apt/sources.list.d/google.list.save <==
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # disabled on upgrade to bionic

==> /etc/apt/sources.list.d/mono-official-preview.list <==
# deb https://download.mono-project.com/repo/ubuntu preview-xenial main

==> /etc/apt/sources.list.d/mono-official-preview.list.distUpgrade <==
# deb https://download.mono-project.com/repo/ubuntu preview-xenial main

==> /etc/apt/sources.list.d/mono-official-preview.list.save <==
# deb https://download.mono-project.com/repo/ubuntu preview-xenial main

==> /etc/apt/sources.list.d/mono-official-stable.list <==
deb https://download.mono-project.com/repo/ubuntu stable-bionic main

==> /etc/apt/sources.list.d/mono-official-stable.list.save <==
deb https://download.mono-project.com/repo/ubuntu stable-bionic main

==> /etc/apt/sources.list.d/mono-xamarin.list <==
# deb http://download.mono-project.com/repo/debian wheezy main

==> /etc/apt/sources.list.d/mono-xamarin.list.distUpgrade <==
# deb http://download.mono-project.com/repo/debian wheezy main

==> /etc/apt/sources.list.d/mono-xamarin.list.save <==
# deb http://download.mono-project.com/repo/debian wheezy main

==> /etc/apt/sources.list.d/mosquitto-dev-ubuntu-mosquitto-ppa-bionic.list <==
deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main

==> /etc/apt/sources.list.d/mosquitto-dev-ubuntu-mosquitto-ppa-bionic.list.save <==
deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main
# deb-src http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu bionic main

==> /etc/apt/sources.list.d/notepadqq-team-ubuntu-notepadqq-xenial.list <==
# deb http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main
# deb-src http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main

==> /etc/apt/sources.list.d/notepadqq-team-ubuntu-notepadqq-xenial.list.distUpgrade <==
# deb http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main
# deb-src http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main

==> /etc/apt/sources.list.d/notepadqq-team-ubuntu-notepadqq-xenial.list.save <==
# deb http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main
# deb-src http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial main

==> /etc/apt/sources.list.d/skype-stable.list <==
# deb [arch=amd64] https://repo.skype.com/deb stable main

==> /etc/apt/sources.list.d/skype-stable.list.distUpgrade <==
# deb [arch=amd64] https://repo.skype.com/deb stable main

==> /etc/apt/sources.list.d/skype-stable.list.save <==
# deb [arch=amd64] https://repo.skype.com/deb stable main

==> /etc/apt/sources.list.d/teamviewer.list <==
###   TeamViewer DEB repository list

### NOTE: Manual changes to this file
###        - prevent it from being updated by TeamViewer package updates
###        - will be lost after using the 'teamviewer repo' command
###       The original file can be restored with this command:
###       cp /opt/teamviewer/tv_bin/script/teamviewer.list /etc/apt/sources.list.d/teamviewer.list
###       which has the same effect as 'teamviewer repo default'

### NOTE: It is preferred to use the following commands to edit this file:
###       teamviewer repo                - show current repository configuration
###       teamviewer repo default        - restore default configuration
###       teamviewer repo disable        - disable the repository
###       teamviewer repo main [stable]  - make all TeamViewer packages available (default)
###       teamviewer repo tv14 [stable]  - make TeamViewer 14 packages available
###                             stable     omit preview and beta releases


### Choose stable main to receive updates for TeamViewer 14 and upcoming major releases
### Choose preview main to receive early updates for TeamViewer 14 and to receive major beta releases

### Choose stable tv14 to receive updates for TeamViewer 14
### Choose preview tv14 to receive early updates for TeamViewer 14

# deb http://linux.teamviewer.com/deb stable main
# deb http://linux.teamviewer.com/deb preview main

# deb http://linux.teamviewer.com/deb stable tv14
# deb http://linux.teamviewer.com/deb preview tv14

==> /etc/apt/sources.list.d/teamviewer.list.save <==
###   TeamViewer DEB repository list

### NOTE: Manual changes to this file
###        - prevent it from being updated by TeamViewer package updates
###        - will be lost after using the 'teamviewer repo' command
###       The original file can be restored with this command:
###       cp /opt/teamviewer/tv_bin/script/teamviewer.list /etc/apt/sources.list.d/teamviewer.list
###       which has the same effect as 'teamviewer repo default'

### NOTE: It is preferred to use the following commands to edit this file:
###       teamviewer repo                - show current repository configuration
###       teamviewer repo default        - restore default configuration
###       teamviewer repo disable        - disable the repository
###       teamviewer repo main [stable]  - make all TeamViewer packages available (default)
###       teamviewer repo tv14 [stable]  - make TeamViewer 14 packages available
###                             stable     omit preview and beta releases


### Choose stable main to receive updates for TeamViewer 14 and upcoming major releases
### Choose preview main to receive early updates for TeamViewer 14 and to receive major beta releases

### Choose stable tv14 to receive updates for TeamViewer 14
### Choose preview tv14 to receive early updates for TeamViewer 14

# deb http://linux.teamviewer.com/deb stable main
# deb http://linux.teamviewer.com/deb preview main

# deb http://linux.teamviewer.com/deb stable tv14
# deb http://linux.teamviewer.com/deb preview tv14

==> /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-xenial.list <==
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

==> /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-xenial.list.distUpgrade <==
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

==> /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-xenial.list.save <==
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

==> /etc/apt/sources.list.d/webupd8team-ubuntu-java-bionic.list <==

==> /etc/apt/sources.list.d/webupd8team-ubuntu-java-bionic.list.save <==

答案1

您从 16.04 到 18.04 的升级似乎没有正确完成,并且您的存储库配置大部分被注释掉了。

要修复 Ubuntu 存储库,编辑/etc/apt/sources.list所以它包含

deb http://ca.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse

deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse

然后运行apt update,你应该能够安装default-jre

您还应该查看 中的所有文件/etc/apt/sources.list.d;如果.list.distUpgrade您觉得这些文件没问题,请重命名它们以删除该.distUpgrade部分。

相关内容