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.

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: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=678195

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

1 Answer 1

Answering my own question:

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

share|improve this answer
@Braiam, I've updated the answer. –  Gili Sep 12 '13 at 20:32

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.