This page details the steps necessary to install Java on the Ubuntu distribution of Linux. The particular steps for each release are listed below.
Ubuntu's repository provides an alternative version of Java SE called OpenJDK. The OpenJDK project attempts to provide an open-source implementation of the Java platform, and is the preferred version of Java for Ubuntu. For more details on OpenJDK, see http://openjdk.java.net/.
Java SE 1.7 is the latest-and-greatest version of Java as of Feb 21, 2012. To install the OpenJDK 1.7 JDK, open a terminal and enter the following. Note that you will need to have an active connection to the internet, and the process will download a fair amount of data (around 50-150 MB).
sudo apt-get install openjdk-7-jdk
You will be prompted for your password (so you can modify the system software), so go ahead and enter it. After calculating what is needed for the install, you should be presented with a list of packages that will be downloaded and installed. Something like this:
The following NEW packages will be installed: default-jre icedtea-7-jre-jamvm icedtea-netx libaccess-bridge-java libaccess-bridge-java-jni libice-dev libpthread-stubs0 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-6-jre openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless openjdk-7-jre-lib x11proto-core-dev x11proto-input-dev x11proto-kb-dev xorg-sgml-doctools xtrans-dev 0 upgraded, 24 newly installed, 0 to remove and 0 not upgraded. Need to get 50.7 MB/51.0 MB of archives. After this operation, 155 MB of additional disk space will be used. Do you want to continue [Y/n]?
Type "Y" and press <Enter> to proceed with the download and installation. When everything finishes, you can verify that the installation succeeded by executing the Java compiler (javac) and checking its version:
user@host:~$ javac -version javac 1.7.0_147
Java SE 1.6 is an older, but more widely-deployed version of the Java platform. Installing this on Ubuntu 11.10 is similar to installing Java SE 1.7, but the package name differs slightly. To install, open a terminal and enter the following:
sudo apt-get install openjdk-6-jdk
The remaining steps should be similar to the instructions above for Java SE 1.7.