Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My automated build server runs a job that depends on Apache Ant. The script invokes apt-get install ant. Ant depends on openjdk-6-jre-headless which runs update-alternatives making itself the default JDK (rewriting my symbolic links in the process). I already had Oracle JDK (manually) installed and do not wish update-alternatives to be run. I cannot manually restore update-alternatives every time this happens.

Someone tried to have this corrected last year but was shot down:

How do I prevent openjdk-6-jre-headless from invoking update-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.

share|improve this question

Answering my own question:

I used 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).

share|improve this answer
@Braiam, I've updated the answer. – Gili Sep 12 '13 at 20:32
On my system, the Oracle JDK was installed at /usr/java/jdk1.7.0_80 and the executables were in the bin directory beneath that. – Michael Oct 29 '15 at 20:06

Your Answer


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.