Friday, August 19, 2011

Installing JDK on Ubuntu 11.04 (Natty Narwhal)

  1. Remove open-jdk (optional)
    sudo apt-get remove openjdk-6-jre
    sudo apt-get autoremove
    
  2. Add repository. You can browse http://archive.canonical.com to know which versions are supported. I'm working with a fresh install of Natty Narwal(11.04)
    sudo add-apt-repository "deb http://archive.canonical.com/ natty partner"
    sudo apt-get update
    
  3. Install software
    sudo apt-get install sun-java6-jre
    sudo apt-get install sun-java6-jdk
    sudo apt-get install sun-java6-plugin
    sudo apt-get install sun-java6-fonts
    
  4. Set global variables editing file /etc/profile
    sudo gedit /etc/profile
    and add the following lines
    export JAVA_HOME = /usr/lib/jvm/java-6-sun
    export PATH = $JAVA_HOME:$PATH
    
    Alternatively you can do the same on /home/[user]/.profile

The JDK will be placed in /usr/lib/jvm/java6-sun.

If you didn't execute step 1, you may need to tell the system which alternative to use with:
sudo update-alternatives --config java
and select the new installation (you'll be prompt with altenatives, don't worry).

No comments:

Post a Comment