how to install jdk on Ubuntu 11.10

Java is one of the most popular programming language and its popularity has undergone an exponential growth (probably because it’s well suitable in distributed environment – you can use Java to develop cool web application with a lot of complex features as well as in developing sophisticated desktop applications, and it’s platform independent – ‘write once and run everywhere‘) in fast few years.

Similarly Ubuntu (latest version : Ubuntu 11.10 beta 1) has become the most popular Linux distro – for desktop environment. That’s why, Ubuntu is now considered as a great platform for developing Java applications.

Anyway, if you are an Ubuntu user and going to start learning Java or a java programmer/developer – want to start coding on Ubuntu, this post is about installing Java Development Kit (JDK) on Ubuntu 11.10 (although it is expected to work on other Debian based Linux distro too). On the other hand if you’re an Ubuntu user, interested only in running java applications then you don’t need to install jdk (it has lot of components which is not required for executing a java program/software) – instead you just need to install jre on Ubuntu 11.10 i.e java runtime environment (includes Java Virtual Machine, for executing java bytecode/class).

Java - jdk for Ubuntu 11.10

Installing Java Development Kit (JDK) on Ubuntu

There’re many JDK available thesedays. One of the most popular – open source jdk is openjdk. OpenJDK is well compatible with Ubuntu/Linux and it is available in official repository – so you can install it a click.

install openjdk on Ubuntu 11.10

Open a terminal (Ctrl+Alt+t) and execute the command(s) –

sudo apt-get install openjdk-7-jdk

OR you can install sunjdk

Update1 : The sun jdk isn’t included with the official repository, so you first need to add a PPA for that; Thanks to Casier :).

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

That’s All..have fun in programming in Java, with Ubuntu!

  • Sivaram

    E: Unable to locate package openjdk-7-jdkHi i am getting the above error message when trying to run sudo apt-get install openjdk-7-jdk

    • Anonymous

      it means that openjdk-7-jdk is not available in official package repository so the package couldn’t be located.. What Ubuntu version you’re using ? as it may not works in older version of Ubuntu..if so then try installing openjdk-6-jdk instead of this.

  • Ricardo A. Hermosilla Carrillo

    sun-java6-jdk doesn’t exists in repos.

  • caiser

    Yes this is all wrong.
    To install the Sun (oracle) jdk, you need to do the following:

    sudo add-apt-repository ppa:ferramroberto/javasudo apt-get updatesudo apt-get install sun-java6-jdk sun-java6-plugin

    • Anonymous

      Thanks for pointing out! Actually when I wrote this article – I had tested with the alpha version of Ubuntu 11.10, and I’m sure it was there in official package repository – so it was unnecessary to add  any external PPA. But in stable release it is not there. So I’ll update the post for correction.

  • BMizzleforizzle

    What if i’d like to use JDK 7?

    • BMizzleforizzle

      sun’s jdk 7.

  • http://twitter.com/Jason0597 Iasonas Papadopoulos


    this worked on my ubuntu netbook.
    sudo apt-get install openjdk-6-jdk

    i was able to install netbeans and start coding. anyway, use this if it works on everyone. 😛

  • Humayun Kabr

    Yes, this is the best and easy solution to install jdk in ubunto. Thanks a lot..