Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to uninstall java 7 and install the version 6 (as some of programs I would like to use are incompatible with 7).

I tried :

$ 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)
share|improve this question

2 Answers 2

up vote 2 down vote accepted

Before removing oracle java you must choose another implementation to provide java. Do so with sudo update-alternatives --config java

Then you should be able to remove it. Or you can leave it as it shouldn't be used at that point.

share|improve this answer
    
After running this command I am still unable to sudo apt-get remove openjdk7-jre. –  Patryk Mar 2 '13 at 18:08

I suppose you are using 12.10 or 13.04. Here default-jre depends on openjdk-7-jre. So you can't remove openjdk-7 without removing also default-jre and break a lot of other dependencies.

But it is no problem to install openjdk-6 beneath openjdk-7.

You can now try to configure the problematic application to use the right jdk or change the default jre with the update-alternatives command. Here is a little helper for this task:

 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.