如何删除 openjdk-7?

如何删除 openjdk-7?

我想卸载 Java 7 并安装版本 6(因为我想使用的某些程序与 7 不兼容)。

我试过 :

$ sudo apt-get remove openjdk-7-jre
[sudo] password for USER: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libatk-wrapper-java-jni : Depends: libatk-wrapper-java (>= 0.30.4-0ubuntu4) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

$ sudo dpkg -r openjdk-7-jre
dpkg: dependency problems prevent removal of openjdk-7-jre:amd64:
 default-jre depends on openjdk-7-jre (>= 7~u3-2.1).
 icedtea-7-plugin:amd64 depends on openjdk-7-jre.
 icedtea-netx:amd64 depends on openjdk-6-jre (>= 6b23~pre10~) | openjdk-7-jre; however:
  Package openjdk-6-jre is not installed.
  Package openjdk-7-jre:amd64 is to be removed.
 openjdk-7-jdk:amd64 depends on openjdk-7-jre (= 7u15-2.3.7-0ubuntu1~12.10).

dpkg: error processing openjdk-7-jre:amd64 (--remove):
 dependency problems - not removing
Errors were encountered while processing:
 openjdk-7-jre:amd64

$ dpkg -l | grep icedtea
ii  icedtea-7-jre-jamvm:amd64                 7u15-2.3.7-0ubuntu1~12.10                  amd64        Alternative JVM for OpenJDK, using JamVM
ii  icedtea-7-plugin:amd64                    1.3-1ubuntu1.1                             amd64        web browser plugin based on OpenJDK and IcedTea to execute Java applets
ii  icedtea-netx:amd64                        1.3-1ubuntu1.1                             amd64        NetX - implementation of the Java Network Launching Protocol (JNLP)
ii  icedtea-netx-common                       1.3-1ubuntu1.1                             all          NetX - implementation of the Java Network Launching Protocol (JNLP)
monkey@ICANSEEYOU:~$ dpkg -l | grep jre
ii  default-jre                               1:1.7-43ubuntu3                            amd64        Standard Java or Java compatible Runtime
ii  default-jre-headless                      1:1.7-43ubuntu3                            amd64        Standard Java or Java compatible Runtime (headless)
ii  icedtea-7-jre-jamvm:amd64                 7u15-2.3.7-0ubuntu1~12.10                  amd64        Alternative JVM for OpenJDK, using JamVM
ri  openjdk-7-jre:amd64                       7u15-2.3.7-0ubuntu1~12.10                  amd64        OpenJDK Java runtime, using Hotspot JIT
ii  openjdk-7-jre-headless:amd64              7u15-2.3.7-0ubuntu1~12.10                  amd64        OpenJDK Java runtime, using Hotspot JIT (headless)
ii  openjdk-7-jre-lib                         7u15-2.3.7-0ubuntu1~12.10                  all          OpenJDK Java runtime (architecture independent libraries)

答案1

在删除 oracle java 之前,您必须选择另一个实现来提供 java。使用sudo update-alternatives --config java

然后你应该可以删除它了。或者你也可以保留它,因为那时它不应该被使用。

答案2

我猜你使用的是 12.10 或 13.04。这里 default-jre 依赖于 openjdk-7-jre。因此,如果不删除 default-jre 并破坏许多其他依赖项,你就无法删除 openjdk-7。

但是在openjdk-7下面安装openjdk-6没有问题。

现在,您可以尝试配置有问题的应用程序以使用正确的 jdk 或使用命令更改默认 jre update-alternatives。以下是此任务的一个小帮手:

 function updateDefaultJava() {
    local pkgArch
    case $(arch) in
        x86_64) pkgArch=amd64;;
        i686)   pkgArch=i386;;
        *)      echo "unhandled architecture $(arch)"; return 1;;
    esac

    local javaBase=/usr/lib/jvm/java-6-openjdk-${pkgArch}
    local cmd
    for cmd in jre/bin/java jre/bin/javaws
    do
        local c=$(basename ${cmd})
        update-alternatives --set ${c} ${javaBase}/${cmd}    || let retC+=$?
        done
    done
    exit ${retC}
 }
 updateDefaultJava

相关内容