The Sun JDK can be installed on Ubuntu by adding a repository and installing with apt-get. The following works with the latest versions of both at the time of writing:

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk

If the command add-apt-repository is missing, install it with the following command:

sudo apt-get install python-software-properties

With the alternatives system in place, the Java executable is automatically available:

/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java

Setting up JAVA_HOME can now be done by editing /etc/profile and adding to the bottom:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
Installing Sun JDK 6 on Ubuntu 10.04
Tagged on:

8 thoughts on “Installing Sun JDK 6 on Ubuntu 10.04

  • 2010-07-07 at 23:12
    Permalink

    Hi,
    good post helped me to run Java on ubantu.
    If you can paste also how to set JAVA_HOME and PATH variables will be a great help for me.

    Thanks,
    Shakil

    Reply
  • 2010-07-15 at 08:25
    Permalink

    Added info on the alternatives system and setting up JAVA_HOME.

    Reply
  • 2010-09-08 at 10:04
    Permalink

    hi

    i like this article.
    i follow this article.

    but I do not know sdk by install 64bit or 32bit version.

    sudo apt-get install sun-java6-jdk

    JDk install is 64bit or 32bit versiono?

    Please

    thanks

    Reply
  • 2010-09-29 at 16:28
    Permalink

    How do you set classpath?

    Reply
  • Pingback:Ubuntu下安装JDK和Eclipse | 咫尺千山路

  • Pingback:Installing JDKs on Ubuntu 10.04 AMI on EC2 « Ultan O'Carroll ( … uoccou … )

  • 2012-10-02 at 12:18
    Permalink

    Hello,
    Thank you very much for posting this tutorial.
    However i am having a problem with the installation. This is the error i get:
    Package sun-java6-jdk is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    E: Package sun-java6-jdk has no installation candidate
    Can you please help me out? Everywhere i read the same thing: Sun Java has been deprecated.No longer in use

    Reply

Leave a Reply to cycjackiechan Cancel reply

Your email address will not be published. Required fields are marked *