I searched through every Google search results and wondered why after updating my apt-get source list, installing Java in Ubuntu still did not work out. It turned out that my source list were lacking some sources in it. If doing this command
apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin
will give you an error that package is not found, go to the source list at
vi /etc/apt/sources.list
and use your text editor to check if these lines are there.
deb http://us.archive.ubuntu.com/ubuntu feisty main restricted
deb http://us.archive.ubuntu.com/ubuntu feisty universe multiverse
If not, add them. Update apt-get again by typing
apt-get update
and then run the same command to install Java 6.
apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin
Follow instructions during installation. To verify that Java 6 has been installed in your system, type
java -version
This post assumes that you are logged in with an account that has root access. If you do not and you are unable to execute any of these commands, add the command sudo.