How to Install Java on Ubuntu


To Install OpenJDK 7 Runtime on Ubuntu, simply we can execute the following command.

sudo apt-get install openjdk-7-jre

Install Firefox / Chromium OpenJDK plugin:

sudo apt-get install icedtea-plugin

If you prefer Java (Sun JDK 7) continue reading. You'll also see how to enable Java plugin for Firefox and Chromium.

Installing Sun Java on Ubuntu 12.04 (64-bit)

  • I downloaded  jdk-7u4-linux-x64.tar.gz file from
  • Using the terminal I goto download folder and extract the tar file content.

$ cd ~/Downloads
$ tar -xvzf jdk-7u4-linux-x64.tar.gz

  • Then I moved the extracted folder to /usr/lib/jvm/

$ sudo mv jdk1.7.0_04 /usr/lib/jvm/

  • Then I installed the files.

$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_04/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_04/bin/java 1
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_04/bin/javaws 1

  • Then I chosed which will default. (For example I have open java installed. But I chosed the new one which is ..jvm/jdk1.7.0_04/... )

$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws

  • I checked the version of java (not necessary, just for information):

$ java -version

Enable Java plugin for Firefox and Chromium in Ubuntu 12.04 (64-bit)

After installing java, by the following command I activated java plugin for Firefox and also for Chromium browser.

$ sudo ln -s /usr/lib/jvm/jdk1.7.0_04/jre/lib/amd64/ /usr/lib/mozilla/plugins

After restarting the browser I see the plugin working by visiting java test page on


Share Share Editor: editor | Posted: 2012/06/12 | Views: 23258


14 + 7 =
Home | Search | Contact | Terms