How to Install an Older Version of Java in Ubuntu 11.04

Update (2011/09/20): As noted by a commenter below, simply extracting the tar or bin installer for Java will work for scripts that don't require a system-wide Java setting. For example, if you extract the JDK in the location "/usr/lib/jvm", update the environment variables in scripts that need to use that version of Java. Usually, you'll only need to update JAVA_HOME and PATH. Example values for these are: "/usr/lib/jvm/jdk1.7.0" and "$PATH:/usr/lib/jvm/jdk1.7.0/bin" respectively. Note that this will work for any version of Java.

If you use the steps below, it will set the installed JVM to be the system default by updating a number of symlinks, including java and javac. Also, it will update the Alternatives Configurator, so that you can use the update-alternatives command to quickly perform system-wide switches between installed Java versions.

Install make-jpkg (also known as java-package)

This package does the job of converting a Java .bin installer to a .deb installer. Run the following command to get this package:

sudo apt-get install java-package

Note that make-jpkg only supports creating .deb packages for the following versions of Java:
      Sun Microsystems(TM) 1.4 and 1.5 Standard Edition
      IBM(TM) 1.3, 1.4, and 5.0 Standard Edition
      Blackdown Java-Linux 1.3 and 1.4 Standard Edition

Download the JDK/JRE

Download the required version of the JDK or JRE from the official download locations.

You can get Sun's JDKs from: Java SE Previous Releases Downloads, and IBM's JDKs from developerWorks : Java™ technology : IBM developer kits : Linux : Download information

Make sure you download the .bin file, and not the .rpm one. Downloading a compressed binary (with a suffix of .tar, .gz or .tgz) will also do.

Create the Debian package for installation

Run the following command to create the .deb package:

fakeroot make-jpkg <file-name>.bin

Install the .deb package

To install the .deb package, simply run:
dpkg -i <file-name>.deb

Verify that your installation is successful using the following command:
java -version


Wow, wow! You make me dizzy with these instructions. Please, do not make Ubuntu/Debian harder to use than Windows! The only difference for JDKs are the PATH and JAVA_HOME environment. I use concurrently JDK 1.4, 5.0 and 7.0 on my Debian install for development purposes. Installed the corresponding .bin files and only switch by script links to PATH and JAVA_HOME when necessary.

By Anonymous

It was exactly what I was needing. Thanks!

By Gustavo

Thanks a lot. Your post helped to start j2ee 1.3 on my ubuntu which requires jdk 1.4.Many many thanks once again :)

By chitvan

Add new comment