无法在 Ubuntu Server 20.04.3 LTS 上安装 Java

无法在 Ubuntu Server 20.04.3 LTS 上安装 Java

所以当我粘贴时:

sudo add-apt-repository ppa:linuxuprising/java

它说:

N: Ignorerar filen ”linuxuprising-” i katalogen ”/etc/apt/sources.list.d/” eftersom den inte har en filändelse

它是瑞典语的,但它基本上会忽略一个文件,因为它没有文件结尾。在此之后,我收到一堆警告,告诉我一些软件包被多次配置。无论我输入什么,它总是会忽略来自 linuxuprising 的文件。我该怎么办?

linuxuprising-java.list的内容为deb http://ppa.launchpad.net/linuxuprising/java/ubuntu focal main。这正常吗?

完整错误信息:

N: Ignorerar filen ”linuxuprising-” i katalogen ”/etc/apt/sources.list.d/” eftersom den inte har en filändelse
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/linuxuprising                                                                                                                        -java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/linuxuprising-j                                                                                                                        ava.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Translations (main/i18n/Translation-sv_SE) is configured multiple times in /etc/apt/sources.list.d/linuxupr                                                                                                                        ising-java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Translations (main/i18n/Translation-sv) is configured multiple times in /etc/apt/sources.list.d/linuxuprisi                                                                                                                        ng-java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/linuxuprisi                                                                                                                        ng-java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/linuxuprising-java.li                                                                                                                        st:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/linuxuprising-java.list                                                                                                                        :1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/linuxuprising                                                                                                                        -java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/linuxuprising-j                                                                                                                        ava.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Translations (main/i18n/Translation-sv_SE) is configured multiple times in /etc/apt/sources.list.d/linuxupr                                                                                                                        ising-java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Translations (main/i18n/Translation-sv) is configured multiple times in /etc/apt/sources.list.d/linuxuprisi                                                                                                                        ng-java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/linuxuprisi                                                                                                                        ng-java.list:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/linuxuprising-java.li                                                                                                                        st:1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/linuxuprising-java.list                                                                                                                        :1 and /etc/apt/sources.list.d/linuxuprising-ubuntu-java-focal.list:1

我尝试过

sudo apt autoremove
sudo apt-get update 
sudo apt-get install openjdk-17-jdk. 

这应该会删除不需要的软件包,更新软件包的内部列表,并安装 OpenJDK。但是当我尝试这些时,它们都不起作用,甚至 也不行apt-get update。这是我收到的错误:

filip@filip:~$ sudo apt autoremove
E: Malformed entry 1 in list file /etc/apt/sources.list.d/linuxuprising.list (Suite)
E: The list of sources could not be read.,
E: Malformed entry 1 in list file /etc/apt/sources.list.d/linuxuprising.list (Suite)
E: The list of sources could not be read.,
filip@filip:~$ sudo apt-get update
E: Malformed entry 1 in list file /etc/apt/sources.list.d/linuxuprising.list (Suite)
E: The list of sources could not be read.,
filip@filip:~$ sudo apt-get install openjdk-17-jdk
E: Malformed entry 1 in list file /etc/apt/sources.list.d/linuxuprising.list (Suite)
E: The list of sources could not be read.,
E: Malformed entry 1 in list file /etc/apt/sources.list.d/linuxuprising.list (Suite)
E: The list of sources could not be read.,

在我将文件扩展名添加到 linuxuprising 目录后,错误现在看起来有些不同。

cat /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://se.archive.ubuntu.com/ubuntu focal main restricted
# deb-src http://se.archive.ubuntu.com/ubuntu focal main restricted

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

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://se.archive.ubuntu.com/ubuntu focal universe
# deb-src http://se.archive.ubuntu.com/ubuntu focal universe
deb http://se.archive.ubuntu.com/ubuntu focal-updates universe
# deb-src http://se.archive.ubuntu.com/ubuntu focal-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 http://se.archive.ubuntu.com/ubuntu focal multiverse
# deb-src http://se.archive.ubuntu.com/ubuntu focal multiverse
deb http://se.archive.ubuntu.com/ubuntu focal-updates multiverse
# deb-src http://se.archive.ubuntu.com/ubuntu focal-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 http://se.archive.ubuntu.com/ubuntu focal-backports main restricted universe                                                                                                                                                              multiverse
# deb-src http://se.archive.ubuntu.com/ubuntu focal-backports main restricted un                                                                                                                                                             iverse 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 focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://se.archive.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://se.archive.ubuntu.com/ubuntu focal-security main restricted
deb http://se.archive.ubuntu.com/ubuntu focal-security universe
# deb-src http://se.archive.ubuntu.com/ubuntu focal-security universe
deb http://se.archive.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://se.archive.ubuntu.com/ubuntu focal-security multiverse
/etc/apt/sources.list.d/
linuxuprising-java.list  linuxuprising-java.list.save  linuxuprising.list  linuxuprising-ubuntu-java-focal.list  linuxuprising-ubuntu-java-focal.list.save  nodesource.list  nodesource.list.save

答案1

N: 忽略文件“linuxuprising-”和目录“/etc/apt/sources.list.d/”,然后将其重命名为

此消息告诉您该文件/etc/apt/sources.list.d/linuxxuprising-被 apt 忽略,因为它没有扩展名。

给文件添加扩展名:

sudo mv /etc/apt/sources.list.d/linuxuprising- /etc/apt/sources.list.d/linuxuprising.list

供将来参考,在提交错误消息之前将语言更改为英语。我碰巧是挪威人,并且足够了解瑞典语,但对于大多数人来说,解释该错误消息有些困难。

要获取英文错误,只需在命令前面加上LANG=c

相关内容