5

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
Kulfy
  • 17,416
  • 26
  • 64
  • 103
Tummala Dhanvi
  • 1,721
  • 3
  • 20
  • 34

1 Answers1

9

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
Anton Dozortsev
  • 1,122
  • 10
  • 21
  • 1
    This is what I am searching for tq for ur answer I will accept as soon as I get it done without getting any errors :) – Tummala Dhanvi Sep 11 '14 at 19:46
  • @dhanvi If you will have some problem ask me here – Anton Dozortsev Sep 11 '14 at 19:50
  • 1
    I would suggest you put it in `/opt` rather than `/usr`. See http://askubuntu.com/questions/34880/use-of-opt-and-usr-local-directories-in-the-context-of-a-pc – user68186 Sep 11 '14 at 19:54
  • @user68186 Check this **[answer](http://unix.stackexchange.com/a/74652/50478)**; `/usr/lib/` - *Libraries for programming and packages...* – Anton Dozortsev Sep 11 '14 at 19:59
  • 2
    `/usr/lib` is where package-managed software goes. These get installed by *Ubuntu Sotware Center*, `apt-get` or `dpkg`. It is best not to put stuff there manually. – user68186 Sep 11 '14 at 20:02
  • 1
    Seconding user68186. Software outside of package management should go into `/usr/local` or `/opt`. – muru Sep 11 '14 at 20:36
  • @AntonDozortsev the alternate method doesn't work for me. FYI I've java 1.7 installed in my pc. Can you please make sure that the second method is still valid? – Mostafiz Rahman Mar 14 '15 at 13:13
  • @mostafiz Now is invalid. Please follow by manual way. – Anton Dozortsev Mar 14 '15 at 13:59