Install JDK7 in Ubuntu (11.10)

Hey all!

Unfortunately, Oracle (Sun) only provides rpm installer packages or tar.gz packed binaries. There’s also no pp archive, or at least i could not find one. That is why I wrote the following tutorial on how to install the Sun JDK7 under Ubuntu. (It’s not the cleanest way, but it is definitely okay to set it up it like that).

More for more

Cheers, Kusi

p.s. This will work in any Ubuntu since 9.04

This tutorial assumes you have a default set up under /usr/lib/jvm. Think when you are following the next steps, change paths accordingly to your downloaded archive / jdk version and path of jvm installations.

  • Download the SDK7 (google “jdk7 download”) as a tar.gz file.
  • Unpack it (tar -xzvf jdk-7-linux-xxxx.tar.gz)
  • Move the extracted folder (currently most probably called jdk1.7.0) to /usr/lib/jvm/jdk1.7.0 (sudo mv jdk1.7.0 /usr/lib/jvm/)
  • Check how many java runtime and devkit installations you already have installed using update-alternatives
    • sudo update-alternatives –config java <- check the highest number available for selection, for example 3 (This would mean we have 4 installed, alternative slots 0,1,2 and 3 are already taken)
    • Remember this number +1 and let’s call it our magic number. This is the position we will put our alternative to. In this example: 4
    • Hit enter to leave without touching the alternative configuration
  • Now, we add the new alternative with the following command. replace the ’4′ with your magic number from the last step
    • sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java 4
  • Now we select our alternative, so again: sudo update-alternatives –config java
  • Select 4 (or whatever your magic number was…)

Enjoy the newest java runtime!

Cheers, kusi

Leave a comment

1 Comments.

  1. Hi Kusi,

    Simple question…why after performing all those command line from your tutorial (which is working fine ) when I do
    $> Which java
    $>/usr/bin/java

    It keeps returning me this Path??

    $>echo $PATH
    $/usr/sbin:/usr/bin:/sbin:/bin:/usr/java/jdk1.7.0_02/bin

    $>echo $JAVA_HOME
    /usr/java/jdk1.7.0_02/bin/java

    I don’t understant…can you help me out please ?

Leave a Reply

You must be logged in to post a comment.