Ubuntu is kind of slow at updating JDK in the official repositories. And not only that but if you've used Ubuntu 10.10 Maverick Meerkat before the final release, you probably know that Java has only been uploaded to the Ubuntu Partner repository a few days before the final release so you could either use the Ubuntu 10.04 repository or manually install Java.
When you manually install JDK, you have to update the paths to get it to work. For this, you can use a script created by WebUpd8 reader Bruce Ingalls (this is actually a new version as we've already wrote a while back about this script) which uses Zenity and can easily update the Java (JDK) paths - all you have to do is select the folder where you've installed Java and the script will do the rest.
The script only works for Ubuntu (10.04 and 10.10) and I've packages the script in a .deb file which is available in the WebUpd8 PPA so you can install it using the following commands (for Ubuntu 10.04 and 10.10):
sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update sudo apt-get install update-java
Or you can manually download the .deb (works with both Lucid and Maverick)
Once installed, you can launch it via the Applications > Other > Update Java menu item.
If you want to use the script without adding the PPA, you can download it from HERE.
In case something doesn't work, you can create a bug report using the following command:
bash -x /usr/bin/update-java > ~/bugreport.txt 2>&1
How to use install the latest Java (JDK) manually (this is just an example for the latest Java JDK):
Firstly, you'll have to download Java (JDK) from HERE. Then you'll have to move the .bin file to /usr/local/ and run it:
sudo mv jdk-6u22-linux-i586.bin /usr/lib/jvm/ sudo chmod +x jdk-6u22-linux-i586.bin sudo ./jdk-6u22-linux-i586.bin
Then simply run the Update Java script - either from the menu (if you've installed the .deb) or manually run the script and select the folder where Java JDK has been installed and select the folder where you've installed JDK manually (in my example it should be /usr/local/jdk1.6.0_22).
Thanks to Bruce Ingalls for the script!