If you're using Ubuntu 11.10 (oneiric ocelot), please check
this entry. Since 11.10, Sun/Oracle's Java JDK has been removed from all (Ubuntu/Canonical) repositories.
Just to summarise the information I got from
http://www.webupd8.org/2011/03/install-java-in-ubuntu-1104-natty.html
and
http://ubuntuforums.org/showthread.php?t=471488
in order to get Sun's Java Development Kit (JDK) up and running under Ubuntu (I'm using 11.04).
You may use Synaptic (the package manager) to add the "Canonical Partners" repository, reload, then find and install sun-java6-jdk.
Otherwise, open a terminal session and type the following:
sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"
or
sudo add-apt-repository "deb http://archive.canonical.com/ natty partner"
...depending on whether you have Ubuntu maverick (10.11) or natty (11.10). Then add:
sudo apt-get update
sudo apt-get install sun-java6-jdk
In case you had OpenJRE, OpenJDK, GCJ or similar (free, OSS Java alternatives) already in your system you may want to ensure Sun's JRE & JDK are the default. Still using the terminal, type:
sudo update-alternatives --config java
and select your preferred alternative from the list. To select a Java compiler, type
sudo update-alternatives --config javac
Now on to the testing. You should get the version numbers of the currently installed and default runtime and compiler by typing (in the terminal):
java -version
javac -version
...and that should be it.
I'd recommend you to use
Geany as a source editor/IDE.