Pledgie



if you think this library has been useful, feel free to give any help. Don't be shy.


Click here to lend your support to: Java2word, coding for fun! and make a donation at www.pledgie.com !

Monday, November 22, 2010

Java Sun JDK 1.5 or 1.6 no Ubuntu 10.10 or 11.04 (updated: 01 Jun 2011)

As we know, Java 1.5 has not been maintained anymore and Java 6, has been hanging around for a while and Java 7 is coming soon. But it doesn't mean everybody has to move on to Java 1.6. The problem in Ubuntu is they force you to use OpenJDK. Worse yet, they don't let you downgrade to 1.5.

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/ubuntu/ jaunty multiverse"

sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse"

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

11 comments:

  1. Thanks for posting

    ReplyDelete
  2. If you ever use Ruby on Ubuntu, have some require 'net/sftp' and see the problem:
    `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

    ReplyDelete
  3. Just what I was looking for, thank you.

    ReplyDelete
  4. Very good, worked fine for me. Thanks a lot !

    ReplyDelete
  5. Thanks a lot Leonardo, I'm working with TinyOS 2.1.1 and it also still need Java 1.5.

    We can also change the current (principal) version of java to 1.5 using :

    sudo update-alternatives --config java

    ReplyDelete
  6. THanks for the tip. But it does not work for me. I got
    # 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

    ReplyDelete
  7. I did the following to get the java5
    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"
    then i did the rest and it worked. thanks

    ReplyDelete
  8. Thanks, by adding last command it is working ... took a lot time to find this solution... Thanks again

    ReplyDelete
  9. thanks... good stuff

    ReplyDelete
  10. Thank you! You helped me a lot! It works on my ubuntu 11.10.

    ReplyDelete