Feb 132011

First you need to check that Ubuntu Partners repository is enabled in your apt sources list, open /etc/apt/sources.list and uncomment the following line:

deb http://archive.canonical.com/ubuntu maverick partner

Then in command line type

sudo apt-get update
sudo apt-get install sun-java6-jdk

As well you need to set Sun Java as default Java provider in your system by typing the following in command line

sudo update-alternatives --config java

You will be presented with the screen similar to this one:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      Priority   Status
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 2

Select the option that has the path /usr/lib/jvm/java-6-sun/jre/bin/java and you are done.
to check if you are using the Sun Java provider type the following:

java -version

You should see a screen similar to the below

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)

  9 Responses to “How to install Sun Java JDK in Ubuntu 10.10 Maverick Meerkat”

  1. Excellent concise instructions. Need a sudo on the update-alternatives line, and maybe to mention you can enable the partner repository through the Ubuntu Software Center GUI.

  2. Thanks. I will update the post with your tips

  3. Great post. Concise.

  4. hey, nice way of explanation.
    I am using ubuntu 10.10
    Since I am new to programming, I am getting something like this.
    rimesh@rimesh-MS-####:~$ sudo update-alternatives –config java
    There is only one alternative in link group java: /usr/lib/jvm/java-6-openjdk/jre/bin/java
    Nothing to configure.
    rimesh@rimesh-MS-####:~$ java -version
    java version “1.6.0_20″
    OpenJDK Runtime Environment (IcedTea6 1.9.7) (6b20-1.9.7-0ubuntu1)
    OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)

    what is the error?
    Can you please explain me how I can install it properly?
    I want to compile a simple “Hello World” Java program, can you please give me the instructions how to compile and run this program?

  5. First you need to install Sun JDK use sudo apt-get install sun-java6-jdk or follow the post step by step from the beginning, to compile java class in the command line you can do the following javac Hello.java

  6. Hi Roger
    Thanks a lot for your help

  7. thanks!!!!!! it helped.

  8. Thank you for the step by step install procedure.. it saved me a lot of time…

  9. Roger,
    Thanks a bunch. It worked even today feb 9, 2012, while ubuntu key servers were timing out during adding the ppa repository.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Get Adobe Flash player