05 February 2013

Install Oracle Java 6 on Debian Wheezy with update-alternatives

Why Would I Want to do That!

I should open this with a statement about why I generally dislike Java as a web technology, in the hope that the sites forcing me to install this software stop using it. I should then make an apology for using the Oracle implementation of Java over some more open project. I'll do neither.

Because there's a well founded scare around the use of Java plugins in web browsers, and because some sites I must use consequently force the use of the most recent Oracle Java, I've installed jdk-6u39-linux-i586.bin from Oracle in a virtual machine, itself using Debian Wheezy.

Quick Procedure

  1. Get the binary installer from Oracle. I'll not link here; it'll probably change anyway
  2. $ chmod 0750 /place/where/downloaded/file/is/jdk-6u39-linux-i586.bin
  3. Get root
  4. # cd /usr/lib/jvm
  5. # /place/where/downloaded/file/is/jdk-6u39-linux-i586.bin
  6. # for j in java javac javaws javadoc javah javap; do update-alternatives --install "/usr/bin/$j" "$j" "/usr/lib/jvm/jdk1.6.0_39/bin/$j" 1066; done
  7. # update-alternatives --config java
  8. # update-alternatives --config javac
  9. # update-alternatives --config javaws
  10. # update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_39/jre/lib/i386/libnpjp2.so" 1066
  11. # update-alternatives --config mozilla-javaplugin.so

Quick Explanation

  1. Download and install Oracle's JDK to /usr/lib/jvm/jdk1.6.0_39
  2. Let your system know about the new Java alternatives it can use, using `update-alternatives --install`
    1. I've used priority 1066 to set it higher than the OpenJDK packages I already had installed
  3. Set your system to use the new alternatives, including the Java web browser plugin, using `update-alternatives --configure`
    1. `update-alternatives --config java` prompts for which alternative you'd like to use. Pick the number for the Oracle version, if it's not already selected
    2. I've shown java, javac, and javaws above, but I also set javadoc, javah and javap


  • $ java -version
  • Open your browser and check that it has the new Java plugin loaded
    • about:plugins in Iceweasel, for example
  • Go to an offending web site and be happy that it now works, as you curse them for using Java in the first place

No comments: