Share this:

Downgrading A Ubuntu Package

I was recently upgrading a couple of Ubuntu machines to the latest and greatest everything. It’s good to be up-to-date makes me feel like a no-nonsense, can-do developer :). Anyways one of the latest and greatest things that Ubuntu pulled in for me was the latest java 6 (JDK 1.6.0_14). All of a sudden my build started failing with strange coverage errors – I hate it when that happens. After looking around for a bit I found that there was a Cobertura issue with java 1.6.0_14, this one. So I though I’d try and downgrade Java 6 to the previous version (who needs to be fully up-to-date anyway, that stuff is for the birds, the real hardcore developers use the penultimate version, yeah!).

This of course was easier said than done, Ubuntu doesn’t really like it when you try to downgrade stuff. I thought that if I could obtain, or create, a debian package with the version of java that I was after I might just be able to manually install that one (yeah that might work). I was wrong, I did get my hands on the debian package that I needed, but Ubuntu spewed out some gaff about dependencies and … long story short, it didn’t work. Of course I could always forgo the use of the package manager and just manually install java and set up the PATH and JAVA_HOME and so forth but that would make me feel a little unclean so I thought I’d persist and do things the easy hard way.

Eventually (after searching around for ages and eating 2 pieces of candy – Vicks VapoDrops – good for the throat) I found a nice Ubuntu forum thread about how to downgrade a package (this one), so here is the summarised version of how to downgrade a Ubuntu package – more specifically my java 6.

Firstly, we need to find what lower versions of our package are available to us, we use the following command:

apt-cache showpkg sun-java6-jdk

This will produce output similar to the following:

Package: sun-java6-jdk
Versions:
6-14-0ubuntu1.9.04 (/var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jaunty-proposed_multiverse_binary-amd64_Packages) (/var/lib/dpkg/status)
Description Language:
File: /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jaunty-proposed_multiverse_binary-amd64_Packages
MD5: cb47d4c49fa7317c472613b7010ef9d8
6-13-1 (/var/lib/apt/lists/au.archive.ubuntu.com_ubuntu_dists_jaunty_multiverse_binary-amd64_Packages)
Description Language:
File: /var/lib/apt/lists/au.archive.ubuntu.com_ubuntu_dists_jaunty_multiverse_binary-amd64_Packages
MD5: cb47d4c49fa7317c472613b7010ef9d8
Reverse Depends:
sun-java6-source,sun-java6-jdk 6-14-0ubuntu1.9.04
sun-java6-javadb,sun-java6-jdk 6-14-0ubuntu1.9.04
sun-java6-demo,sun-java6-jdk
sun-java6-demo,sun-java6-jdk 6-14-0ubuntu1.9.04
libnb-java2-java,sun-java6-jdk
libnb-java2-java,sun-java6-jdk
sun-java6-source,sun-java6-jdk 6-13-1
sun-java6-javadb,sun-java6-jdk 6-13-1
sun-java6-demo,sun-java6-jdk
sun-java6-demo,sun-java6-jdk 6-13-1
glassfishv2-bin,sun-java6-jdk
glassfishv2,sun-java6-jdk
Dependencies:
6-14-0ubuntu1.9.04 - sun-java6-bin (5 6-14-0ubuntu1.9.04) libc6 (0 (null)) libx11-6 (0 (null)) debconf (18 0.5) debconf-2.0 (0 (null)) sun-java6-demo (0 (null)) sun-java6-doc (0 (null)) sun-java6-source (0 (null))
6-13-1 - sun-java6-bin (5 6-13-1) libc6 (0 (null)) libx11-6 (0 (null)) debconf (18 0.5) debconf-2.0 (0 (null)) sun-java6-demo (0 (null)) sun-java6-doc (0 (null)) sun-java6-source (0 (null))
Provides:
6-14-0ubuntu1.9.04 - java6-sdk java5-sdk java2-sdk java2-compiler java-sdk java-compiler
6-13-1 - java6-sdk java5-sdk java2-sdk java2-compiler java-sdk java-compiler
Reverse Provides:

There are two versions available in the repository. As we can see the java version we are looking for (6-13-1) is here. However it is worth noting that had we wanted to downgrade several versions back, we would be out of luck as older versions are no longer in the repository.

Now that we see the version that we want we need to do the following to downgrade:

sudo aptitude install sun-java6-jdk=6-13-1

This will produce something along the lines of:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following packages are BROKEN:
sun-java6-jdk
0 packages upgraded, 0 newly installed, 1 downgraded, 0 to remove and 2 not upgraded.
Need to get 17.7MB of archives. After unpacking 1925kB will be freed.
The following packages have unmet dependencies:
sun-java6-jdk: Depends: sun-java6-bin (= 6-13-1) but 6-14-0ubuntu1.9.04 is installed.
The following actions will resolve these dependencies:
Remove the following packages:
sun-java6-fonts
sun-java6-plugin
Downgrade the following packages:
sun-java6-bin [6-14-0ubuntu1.9.04 (jaunty-proposed, now) -> 6-13-1 (jaunty)]
sun-java6-jre [6-14-0ubuntu1.9.04 (jaunty-proposed, now) -> 6-13-1 (jaunty)]
Score is 188
Accept this solution? [Y/n/q/?]  Y
The following packages will be DOWNGRADED:
sun-java6-bin sun-java6-jdk sun-java6-jre
The following packages will be REMOVED:
sun-java6-fonts{a} sun-java6-plugin{a}
0 packages upgraded, 0 newly installed, 3 downgraded, 2 to remove and 2 not upgraded.
Need to get 50.7MB of archives. After unpacking 4096kB will be freed.
Do you want to continue? [Y/n/?] Y

If we now run:

java -version

We get:

java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)

Which is the downgraded java that we were after, sweet!

  • http://www.christianconservative.ca Christian Conservative

    Dude, you so saved my bacon with this command: sudo aptitude install sun-java6-jdk=6-13-1

    Was working on something the other week, and I installed Java 6-14, and my SSL-VPN client has been giving me no end of grief. Been trying to figure out what it was, and realized it was the Java. Your posting of the command I needed saved me a whole ton of work! Thanks!

    • http://www.skorks.com Alan Skorkin

      You’re more than welcome :)

  • sola

    Thanks for this post, it saved me a lot of time when I realized that Sun Java 1.6 u14 is SCREWED.

    My problem findings with Java on Jaunty:
    http://ubuntuforums.org/showthread.php?p=7653716#post7653716

    • http://www.skorks.com Alan Skorkin

      Yeah, I didn’t think I’d be the only one with JDK 1.6.0_14 issues.
      Glad I could help.

  • sola

    It is worth to pin the sun-java6* packages (with Synaptic you can do that easily) because the Update Manager will automatically update from 13 to 14 next time you run a symple system update.

    The pins can be removed after the issues have been resolved with 14.

    • http://www.skorks.com Alan Skorkin

      This is a great tip, synaptic does have the ability to pin packages so that they don’t get updated when newer versions come out, thanks for sharing it.

  • Hiroe

    it’s “An Ubuntu”

    • http://www.skorks.com Alan Skorkin

      Hmm, from a strictly grammatical point of view you’re probably correct (infact you ARE correct as far as I know). However it sounds a bit funny if you say “An Ubuntu” out loud, so I prefer to stick with “A Ubuntu”, which is a lot easier on the ear.

  • Pingback: Revertendo atualização (downgrade) de pacotes no Debian/Ubuntu « Linux… e mais coisas()

  • Mike

    If it sounds funny then you must be pronouncing Ubuntu incorrectly. “An” does go before all words beginning with vowels, *except* when the letter u makes the same sound as the y in you, or o makes the same sound as w in won, then a is used. So you must be pronouncing Ubuntu as “yoo-bun-too” but it is actually pronounced “oo-boon-too” according to the official Ubuntu site, and Nelson Mandela.

    Please see:

    http://danielmiessler.com/blog/this-is-how-you-pronounce-ubuntu

  • John

    funny, it didn’t work for me. tried to downgrade from 1.6.0_18 to 17 (same issues as 14 causing crashes). I don’t see the previous version (17) when I check the cache. any ideas where to get it from? Background: my JDownloader is throwing Java erros and crashing. I read that downgrading to 1.6.0_17 fixes it.

  • http://www.elmar.nl Jonas

    Hi all,

    I have had the same problem as you with the version 6.26. And as John , in my case the old version is not in the cache.

    I downloaded the version 6.22 from this place http://ftp.nl.debian.org/debian/pool/non-free/s/sun-java6/ and with the version in the cache, I installed the version 6.22 following using
    sudo aptitude install sun-java6-jdk=6-22…

    Thanks for your help.

  • http://gfxmonk.net Tim

    Since you seem to have such good google-juice for “downgrade ubuntu package”, I thought I’d add a link to the hail many of downgrading (the “emergency downgrade”), for folks who are in a more desperate position:

    http://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_emergency_downgrading

    If you try to use your simple method to downgrade something important (like gtk), apt goes a bit mad and tries to install half of KDE. It is a scary time.

  • Pingback: Python Disabled in QGIS? | Northwest Spatial Solutions()

  • SweetDrooler

    Just dropped by to say thanks ! I was able to downgrade VLC in a similar manner because it had some problems with MKV. You saved my day !