Ubuntu – How to install JDK 1.5

javajdk

I am getting this error when trying to install java 1.5 JDK

sudo apt-get install sun-java5-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package sun-java5-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
However the following packages replace it:
  apt:i386 apt

E: Package 'sun-java5-jdk' has no installation candidate

Best Answer

  • Download JDK 5

    Create directory for JDK:

    sudo mkdir /usr/lib/jvm/java5
    

    Extract archive in a new folder:

    sudo tar xf java5.tar.gz -C /usr/lib/jvm/java5
    

    Now run:

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java5/jdk1.5.0/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java5/jdk1.5.0/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java5/jdk1.5.0/bin/javaws" 1
    

    Correct the file ownership and the permissions of the executables:

    sudo chmod a+x /usr/bin/java
    sudo chmod a+x /usr/bin/javac
    sudo chmod a+x /usr/bin/javaws
    sudo chown -R root:root /usr/lib/jvm/java5/jdk1.5.0
    

    Check if it successful:

    java -version
    
  • Related Question