尝试安装 snapd 时发生 Java 错误

尝试安装 snapd 时发生 Java 错误

我最近尝试在我的 Debian 10 VPS 上安装 snapd,当我遇到以下错误时:

Setting up jdk1.8 (1.8.0271-1) ...
Unpacking JAR files...
        tools.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/lib/tools.pack
        plugin.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/plugin.pack
        javaws.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/javaws.pack
        deploy.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/deploy.pack
        rt.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/rt.pack
        jsse.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/jsse.pack
        charsets.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/charsets.pack
        localedata.jar...
Error: Could not open input file: /usr/java/jdk1.8.0_271-amd64/jre/lib/ext/localedata.pack
update-alternatives: error: alternative jar can't be slave of java: it is a master alternative
dpkg: error processing package jdk1.8 (--configure):
 installed jdk1.8 package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 jdk1.8
E: Sub-process /usr/bin/dpkg returned an error code (1)

控制台输出

我的更新选项或 java 安装似乎有问题。我已经尝试搜索提示:alternative jar can't be slave of java: it is a master alternative 但我无法理解它。我已经尝试更新我的软件包,但这似乎也没有影响。

我将衷心感谢您的帮助。

答案1

解决方法:

alternative jar can't be slave of java: it is a master alternative

您需要将 java 添加到update-alternatives

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.8.0_271-amd64/bin/java 100
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk1.8.0_271-amd64/bin/javac 100 \
--slave "/usr/bin/jar" "jar" "/usr/java/jdk1.8.0_271/bin/jar"

解决以下错误:

dpkg: error processing package jdk1.8 (--configure):
 installed jdk1.8 package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 jdk1.8
E: Sub-process /usr/bin/dpkg returned an error code (1)

请参阅 U&L 上的这个答案。

相关内容