How to prevent openjdk-6-jre-headless from clobbering Oracle JDK installation?
Answering my own question:
I used https://askubuntu.com/a/55960/23678 to install Oracle JDK. As you can see, these instructions invoke update-alternatives
with a priority of 1. When openjdk-6-jre-headless
installs itself it sets a priority of 1061 (where a higher priority replaces lower ones).
In order to fix this problem I simply gave Oracle JDK a priority higher than 1061. When openjdk-6-jre-headless
installed itself, it no longer clobbered Oracle JDK as the default.
UPDATE: To update OpenJDK's priorities I simply re-ran:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 2000
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 2000
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 2000
with a priority of 2000 instead of 1 (the priority is the last command-line argument).
Related videos on Youtube
Gili
Updated on September 18, 2022Comments
-
Gili over 1 year
My automated build server runs a job that depends on Apache Ant. The script invokes
apt-get install ant
. Ant depends onopenjdk-6-jre-headless
which runsupdate-alternatives
making itself the default JDK (rewriting my symbolic links in the process). I already had Oracle JDK (manually) installed and do not wishupdate-alternatives
to be run. I cannot manually restoreupdate-alternatives
every time this happens.Someone tried to have this corrected last year but was shot down: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=678195
How do I prevent
openjdk-6-jre-headless
from invokingupdate-alternatives
or, worse case scenarion, how do I look up the value before the installation process and restore it after-the-fact?UPDATE: I filed a new bug report here. I would appreciate your support.
-
Gili over 10 years@Braiam, I've updated the answer.
-
michaelsinner over 8 yearsOn my system, the Oracle JDK was installed at /usr/java/jdk1.7.0_80 and the executables were in the bin directory beneath that.