Since I haven't seen any how to's on how to install Sun's java (Any Version) I thought I'd write up a little how to.
First you will need to add all the extra repositories for Ubuntu. (ie Multiverse, Universe...) Please see other how to's on how to do that.
Now go to Sun's website http://java.sun.com and select the java jdk or jre that you want. In my case I needed 1.4.2 so I downloaded j2sdk-1_4_2_09-linux-i586.bin.
Then run the following commands from the terminal:
First install the required packages:
sudo apt-get install fakeroot java-package java-common
Create the Deb file for the install:
fakeroot make-jpkg jre-1_5_0_05-linux-i586.bin
Install The deb file
sudo dpkg -i sun-j2re1.5_1.5.0+update05_i386.deb
Now make Sun's java the default by running this command and selecting it.
sudo update-alternatives --config java
I hope that helps.
The instructions above are dated, please do not use them. Use the following instead:
Execute one of the following:
sudo apt-get install sun-java6-jdk - For the JDK (Developer)
sudo apt-get install sun-java6-jre - For the JRE (User)