There are lots of legacy systems running on Java 5 and we can't forget that. It is also about freedom of choice. If you want to install Sun JDK 5 or 6 Ubuntu should not make your life difficult.
Ubuntu 10 and 11 don't allow us to natively (or easily) install Sun JDK's via apt-get.
It is so frustrate when we try to install it on Ubuntu 10.10 and have no luck:
sudo apt-get install sun-java5-jdk (or sudo apt-get install sun-java6-jdk)
After installed, the JDK will go to this directory: /usr/lib/jvm/java-6-sun
You can see all JDK's installed running the following command:
sudo update-java-alternatives -l
After a while, finally got the solution for this:
sudo add-apt-repository "deb http://us.archive.ubuntu.com/
sudo add-apt-repository "deb http://us.archive.ubuntu.com/
sudo apt-get update
sudo apt-get install sun-java5-jdk
Check it out just to confirm:
sudo update-java-alternatives -l
The commands above worked for me in Ubuntu 10 and 11, installing Sun JDK 1.5 and 1.6.
If it doesn't work, try to add the following repositories and repeat the process: (anonymous suggestion - thanks a lot):
sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse"
sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse"
Cheers
Leonardo
Thanks for posting
ReplyDeleteIf you ever use Ruby on Ubuntu, have some require 'net/sftp' and see the problem:
ReplyDelete`require': no such file to load -- net/sftp (LoadError)
Add the following line before the require:
require 'rubygems'
I am used to Mac and now having all these issues...
Leonardo
Just what I was looking for, thank you.
ReplyDeleteVery good, worked fine for me. Thanks a lot !
ReplyDeleteThanks a lot Leonardo, I'm working with TinyOS 2.1.1 and it also still need Java 1.5.
ReplyDeleteWe can also change the current (principal) version of java to 1.5 using :
sudo update-alternatives --config java
THanks for the tip. But it does not work for me. I got
ReplyDelete# sudo apt-get install sun-java5-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package sun-java5-jdk
Any pointers?
-sathiya
I did the following to get the java5
ReplyDeletesudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse"
sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse"
then i did the rest and it worked. thanks
Thanks, by adding last command it is working ... took a lot time to find this solution... Thanks again
ReplyDeletethanks... good stuff
ReplyDeleteThank you! You helped me a lot! It works on my ubuntu 11.10.
ReplyDeleteThanks! You helped me! It works on my ubuntu 11.10.
ReplyDeleteThanks. Works fine for me too.... :)
ReplyDeletecheers man. works like a charm
ReplyDeletethanks...first option worked for me
ReplyDeleteYou really helped me out..it's been in long i have problem with installing java 1.5...that's what i really wanted and liked here...
ReplyDeletethanks again
Thanks a lot for the post. It worked fine to me.
ReplyDeleteThanks Leonardo & Anon... I had to use the Hardy repos too... can I also suggest running:
ReplyDeletesudo add-apt-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse"
sudo add-apt-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse"
and/or:
sudo add-apt-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse"
sudo add-apt-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse"
After the installation (the repos are not getting updated now, so no use keeping them) to avoid any accidental repo misuse later (bonus ... if the repos failed to be added for some reason the remove commands will throw an error :D)