Tuesday, May 15, 2012

How to install sun-java or sun JDK/JRE in ubuntu

Problem:
Tried to install java using following command:

sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jre
 but got an error message as follows
reading package lists.... done
building dependency tree
reading state information .... done
package sun-java6-jdk is  not available
it has no installation candidate

The solution is :
For Ubuntu 10.04 LTS, the sun-java6 packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.
If you can not switch from the proprietary Sun JDK/JRE to OpenJDK, you can install sun-java6 packages from the Canonical Partner Repository. You can configure your system to use this repository via command-line:
     sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
     sudo apt-get update   
     sudo apt-get install sun-java6-jre sun-java6-plugin
     sudo apt-get install sun-java6-jdk 
      sudo update-alternatives --config java
For Ubuntu 10.10, the sun-java6 packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.
If you can not switch from the proprietary Sun JDK/JRE to OpenJDK, you can install sun-java6 packages from the Canonical Partner Repository. You can configure your system to use this repository via command-line:
     sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"
     sudo apt-get update   
     sudo apt-get install sun-java6-jre sun-java6-plugin
        
      sudo apt-get install sun-java6-jdk
      sudo update-alternatives --config java

Source:  https://wiki.ubuntu.com/LucidLynx/ReleaseNotes#Sun%20Java%20moved%20to%20the%20Partner%20repository



If above does not work (for other version of ubuntu) then you can create local repository as follows:




cd ~/
wget https://github.com/flexiondotorg/oab-java6/raw/0.2.1/oab-java6.sh -O oab-java6.sh
chmod +x oab-java6.sh
sudo ./oab-java6.sh

and then run:
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jre

Source :   https://github.com/flexiondotorg/oab-java6/blob/a04949f242777eb040150e53f4dbcd4a3ccb7568/README.rst

No comments:

Post a Comment