There are several JDK implementations available for Linux, such as Oracle JDK 7, OpenJDK, Sun JDK 6, IBM JDK and GNU Java Compiler. We shall choose the Oracle JDK 7 (Ubuntu chooses OpenJDK as its default JDK, which is not 100% compatible with Oracle JDK).
Step 1 : Check if JDK has already been Installed
Open a Terminal or press Ctrl + Alt + T and issue this command:
javac -version
If a JDK version number (e.g., "javac 1.7.0_{xx}") appears, JDK has already been installed. You can skip the installation and goto step 3.
Step 2 : Download and Install JDK
Goto JDK (Java SE) download site at
Select "Java SE 7ux" ⇒ JDK ⇒ Download ⇒ "Accept Licence Agreement" ⇒ Select Linux x86 (for 32-bit system) or Linux x64 (for 64-bit system) "tar.gz" package, e.g., "jdk-7ux-linux-i586.tar.gz". The tarball will be stored in folder "~/Downloads", by default.
We shall install JDK under "/usr/lib/jvm". First, create a directory "jvm" under "/usr/lib" (with superuser authority "sudo"). Open a Terminal and issue these commands:
cd /usr/lib
sudo mkdir jvm