apt-get升级后无法安装java

apt-get升级后无法安装java

当我执行 java -version 时,我得到:

bash: /usr/bin/java: No such file or directory

我遵循了多个在线指南来安装 java。我遵循了所有步骤,但仍然收到该错误。也许我做错了——我不知道。

输出:dpkg -l jdk*

dpkg-query: no packages found matching jdk*

输出:ls -l /usr/bin/java

lrwxrwxrwx 1 root root 22 Nov 16 17:21 /usr/bin/java -> /etc/alternatives/java

输出:sudo add-apt-repository ppa:webupd8team/java

add-apt-repository: command not found

输出:file "$(readlink -e "$(type -P java)")"

/usr/local/java/jdk1.7.0_45/bin/java: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, BuildID[sha1]=0x6849323f527575e206a1b6449617e809158e82be, not stripped

输出ldd "$(readlink -e "$(type -P java)")

not a dynamic executable

Debian 版本,输出uname -a

Linux Cyneox 3.7-trunk-amd64 #1 SMP Debian 3.7.2-0+kali8 x86_64 GNU/Linux

@特蕾莎·E·朱尼尔

抱歉,由于静态链接问题,我无法对这些帖子发表评论。 python-software-properties 返回了此错误,这是我尝试安装的大多数程序所得到的错误:

    E: Package 'python-software-properties' has no installation candidate

另外,我运行了您上面所说的命令,并且输入 java -version 仍然没有执行任何操作。

Joseph R,这就是我输入的内容:

root@Cyneox:/usr/bin# apt-get install ia32-libs ia32-libs:i386
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package ia32-libs 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 'ia32-libs' has no installation candidate
E: Unable to locate package ia32-libs

root@Cyneox:/usr/bin# apt-get install openjdk-7-jre
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package openjdk-7-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 'openjdk-7-jre' has no installation candidate

但你给我的前两行有效。

的输出cat /etc/apt/sources.list /etc/apt/sources.list.d/*

# 

# deb cdrom:[Debian GNU/Linux 7.0 _Kali_ - Official Snapshot amd64 LIVE/INSTALL Binary 20130905-07:57]/ kali contrib main non-free

#deb cdrom:[Debian GNU/Linux 7.0 _Kali_ - Official Snapshot amd64     LIVE/INSTALL     Binary 20130905-07:57]/ kali contrib main non-free

## Security updates
# Line commented out by installer because it failed to verify:
#deb http://security.kali.org/kali-security kali/updates main contrib non-free
deb http://http.debian.net/debian/ wheezy-backports main contrib
deb http://archive.canonical.com/ lucid partner
cat: /etc/apt/sources.list.d/*: No such file or directory

约瑟夫,我在更新中应用了您的修复,一切都很顺利......直到:

Setting up openjdk-7-jre-headless:amd64 (7u25-2.3.10-1~deb7u1) ...
update-alternatives: error: cannot stat file '/etc/alternatives/java': Too many levels of symbolic links
dpkg: error processing openjdk-7-jre-headless:amd64 (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of ca-certificates-java:
 ca-certificates-java depends on openjdk-6-jre-headless (>= 6b16-1.6.1-2) | java6-runtime-headless; however:
  Package openjdk-6-jre-headless is not installed.
  Package java6-runtime-headless is not installed.
  Package openjdk-7-jre-headless:amd64 which provides java6-runtime-headless is not configured yet.

dpkg: error processing ca-certificates-java (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-7-jre:amd64:
 openjdk-7-jre:amd64 depends on openjdk-7-jre-headless (= 7u25-2.3.10-1~deb7u1); however:
  Package openjdk-7-jre-headless:amd64 is not configured yet.

dpkg: error processing openjdk-7-jre:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of icedtea-7-jre-jamvm:amd64:
 icedtea-7-jre-jamvm:amd64 depends on openjdk-7-jre-headless (= 7u25-2.3.10-1~deb7u1); however:
  Package openjdk-7-jre-headless:amd64 is not configured yet.

dpkg: error processing icedtea-7-jre-jamvm:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-7-jre-lib:
 openjdk-7-jre-lib depends on openjdk-7-jre-headless (>= 7~b130~pre0); however:
  Package openjdk-7-jre-headless:amd64 is not configured yet.

dpkg: error processing openjdk-7-jre-lib (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 openjdk-7-jre-headless:amd64
 ca-certificates-java
 openjdk-7-jre:amd64
 icedtea-7-jre-jamvm:amd64
 openjdk-7-jre-lib
E: Sub-process /usr/bin/dpkg returned an error code (1)

然后我尝试了apt-get -f install,但还是失败了......

答案1

在我看来,这听起来像是无法在 64 位计算机上运行 32 位应用程序的长期问题。我们在这里多次讨论过这个问题(参见参考我对类似问题的回答末尾的部分)。

假设您正在运行 Debian Wheezy,您需要i386首先添加架构才能下载 32 位库:

# dpkg --add-architecture i386
# apt-get update
# apt-get install ia32-libs ia32-libs:i386

但是,不要这样做。正如 Teresa 的直觉,您的 Java 安装似乎来自第三方来源,这就是为什么它是 32 位的,而您有 64 位操作系统。我建议您从存储库安装 Java:

# apt-get install openjdk-7-jre

应该可以解决问题。

更新

根据您的附加信息,请将 Debian 稳定存储库添加到您的/etc/sources.list

# echo 'deb http://ftp.debian.org/debian/ stable main contrib non-free' >>/etc/apt/sources.list
# apt-get update # may take a while
# apt-get install openjdk-7-jre

笔记

  • openjdk-7-jre旨在安装 Java 运行时环境版本 7,这是撰写本文时的最新版本(在 Debian 稳定存储库中)。对于其他版本,请适当替换7
  • 根据您对软件自由的信念,您可能需要删除上述命令的contribnon-free部分,因为它们使您能够安装专有的闭源软件。

参考

答案2

实际上,你已经在 下安装了 Java /usr/local/java/jdk1.7.0_45/,这不是 Debian 中的官方路径,但一定是从第三方软件包(例如来自 Oracle 网站的软件包)安装的结果。它只是没有链接到/usr/bin.您可以通过运行 Java 来直接使用 Java /usr/local/,也可以将其链接到/usr/bin

sudo update-alternatives --install /etc/alternatives/java java /usr/local/java/jdk1.7.0_45/bin/java 1

这应该足够了。尝试运行一下/usr/bin/java看看是否有效。

现在,关于你尝试的另一种方法,你的问题中有一个混淆:你正在使用 Debian 并按照有关如何在乌班图。您也可以尝试在 Debian 上从 WebUpd8 PPA 安装 Java,但我不能向您保证它会起作用:

python 软件属性包含命令添加 apt 存储库:

sudo apt-get install python-software-properties

然后您可以像以前一样继续遵循安德鲁的指示。最糟糕的情况是 APT 拒绝为您安装 Java。

相关内容