8

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.

1 Answer 1

11

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

2
  • @Braiam, I've updated the answer.
    – Gili
    Sep 12, 2013 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, 2015 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .