Installing Sun JDK 6 on Ubuntu 10.04

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

7 Responses

Write a Comment»
  1. 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

  2. Added info on the alternatives system and setting up JAVA_HOME.

  3. thanks a lot

  4. 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

  5. How do you set classpath?

  6. [...] 2,装JDK,我用的这个链接:http://www.jansipke.nl/installing-sun-jdk-6-on-ubuntu-10-04。只要是Ubuntu把Sun JDK去掉,换成了OpenJDK。 [...]

  7. [...] might guess – but thats too easy.  Sun JDK6 is now in an archive repository, so you need to add that and then, wait for it, your instance hangs. So, Im about to try to fix that, by following [...]

Leave a Reply

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

*

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>