在 OpenSuse 42.3 上安装 Java 9 时出现“cp: cannot stat”错误

Posted

技术标签:

【中文标题】在 OpenSuse 42.3 上安装 Java 9 时出现“cp: cannot stat”错误【英文标题】:"cp: cannot stat" error while installing Java 9 on OpenSuse 42.3 【发布时间】:2017-09-27 19:49:34 【问题描述】:

我正在尝试在 OpenSuse 42.3 上安装 Java 9。 我已下载 java 9 rpm 文件并尝试在 OpenSuse 42.3 上安装,但出现以下错误。

user@localhost:~> sudo rpm -ivh Downloads/jdk-9_linux-x64_bin.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-9-2000:9-ga                  ################################# [100%]
Unpacking JAR files...
    plugin.jar...
    javaws.jar...
    deploy.jar...
cp: cannot stat '/usr/java/jdk-9/lib/desktop/icons/hicolor/16x16/apps/sun-java.png': No such file or directory
cp: cannot stat '/usr/java/jdk-9/lib/desktop/icons/hicolor/16x16/apps/sun-javaws.png': No such file or directory
cp: cannot stat '/usr/java/jdk-9/lib/desktop/icons/hicolor/48x48/apps/sun-java.png': No such file or directory
cp: cannot stat '/usr/java/jdk-9/lib/desktop/icons/hicolor/48x48/apps/sun-javaws.png': No such file or directory
cp: cannot stat '/usr/java/jdk-9/lib/desktop/icons/hicolor/48x48/apps/sun-java.png': No such file or directory
cp: cannot stat '/usr/java/jdk-9/lib/desktop/icons/hicolor/48x48/apps/sun-javaws.png': No such file or directory
update-alternatives: using /usr/java/jdk-9/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: error: alternative appletviewer can't be slave of javac: it is a slave of java
warning: %post(jdk-9-2000:9-ga.x86_64) scriptlet failed, exit status 2

我该如何解决这个问题?

【问题讨论】:

这可能是因为创建文件夹的权限被拒绝或未能找到 cp/scp 的相关权限?恕我直言,这应该移至unix.stackexchange 很难相信由于权限而导致安装失败,因为我正在使用sudo 进行安装。能否请您告诉我如何将其移至 unix.stackexchange? 您可以在那里创建一个问题并关闭此帖子以移至 unix.stackexchange。 在 RHEL 7.4 中实现相同 【参考方案1】:

我在 Centos7 上安装了 Java 9.0.4,只收到“无法统计”消息,但安装似乎没问题:

sudo rpm -ivh jdk-9.0.4_linux-x64_bin.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-9.0.4-2000:9.0.4-ga          ################################# [100%]
Unpacking JAR files...
    plugin.jar...
    javaws.jar...
    deploy.jar...
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/hicolor/16x16/apps/sun-java.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/hicolor/16x16/apps/sun-javaws.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/hicolor/48x48/apps/sun-java.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/hicolor/48x48/apps/sun-javaws.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/HighContrast/16x16/apps/sun-java.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/HighContrast/16x16/apps/sun-javaws.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/HighContrast/48x48/apps/sun-java.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/HighContrast/48x48/apps/sun-javaws.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/hicolor/48x48/apps/sun-java.png’: No such file or directory
cp: cannot stat ‘/usr/java/jdk-9.0.4/lib/desktop/icons/hicolor/48x48/apps/sun-javaws.png’: No such file or directory
:

安装后的目录树如下:

:tree /usr/java/jdk-9.0.4/lib/desktop/icons

/usr/java/jdk-9.0.4/lib/desktop/icons
├── hicolor
│   ├── 16x16
│   │   ├── apps
│   │   │   └── sun-jcontrol.png
│   │   └── mimetypes
│   │       ├── gnome-mime-application-x-java-archive.png
│   │       ├── gnome-mime-application-x-java-jnlp-file.png
│   │       └── gnome-mime-text-x-java.png
│   └── 48x48
│       ├── apps
│       │   └── sun-jcontrol.png
│       └── mimetypes
│           ├── gnome-mime-application-x-java-archive.png
│           ├── gnome-mime-application-x-java-jnlp-file.png
│           └── gnome-mime-text-x-java.png
├── HighContrast
...

【讨论】:

以上是关于在 OpenSuse 42.3 上安装 Java 9 时出现“cp: cannot stat”错误的主要内容,如果未能解决你的问题,请参考以下文章

在 Opensuse 42.3 上为 haskell 堆栈设置 ghc-8.2.1 时出现 ghc 完整性检查错误

OpenSUSE Leap 42.3下通过Firefox Opera Chromium浏览器直接执行java应用程序(打开java jnlp文件)实现在服务器远程虚拟控制台完成远程管理的方法

open suse 42.3常用软件源(包括阿里云)

在 OpenSUSE 上使用 PHP-FPM 安装 OCI8

用于 Leap 42.3 的 Rails

vim 在 Docker 容器中使用时不突出显示语法