Installing sun Java on Debian or Ubuntu
Because sun now is moving java toward a GPL license, latest Debian version, finally provide packages for java, though they are still classified as 'non-free'.
You should try this first as this is simpler / more maintainable.
Add support for 'non-free' packages
sudo vi /etc/apt/sources
deb http://ftp.us.debian.org/debain etch main non-free
then run sudo apt-get update
to update the package list.
Now you can install dun jdk 1.5: sudo apt-get install sun-java5-jre
Old school way
If you have an older Debian version, or do not want to use a package classified as 'non-free' you can go the old way:
sudo apt-get update
sudo apt-get install java-package java-common fakeroot
Download the sun jdk from java.sun.com
Edit /usr/share/java-package/sun-j2sdk.sh to reflect the actual JDK 1.5 release version.
fakeroot make-jpkg jdk-1_5_0-linux-i586.bin
sudo dpkg -i sun-j2sdk1.5_1.5.0_i386.deb
#Note: if you have already another version fo java you might want to specify which one to use:
sudo update-alternatives --config java