How to remove openjdk-7?
Solution 1
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.
Solution 2
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
Related videos on Youtube
![Patryk](https://i.stack.imgur.com/jTqPB.png?s=256&g=1)
Patryk
Software Engineer C++/Go/shell/python coder Linux enthusiast Github profiles: https://github.com/pmalek https://github.com/pmalekn
Updated on September 18, 2022Comments
-
Patryk almost 2 years
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)
-
Patryk over 11 yearsAfter running this command I am still unable to
sudo apt-get remove openjdk7-jre
.