Monday, 8 August 2011

Installing oracle sun jdk 1.7 on ubuntu 11.04

Install JDK 7 on Ubuntu

Install JDK 7 on Ubuntu
Install JDK 7 on Ubuntu
Task: Install JDK 7 on Ubuntu desktop.
Problem 1: Java version 7 is not available from the official Ubuntu repositories. You don’t see it neither via "Ubuntu Software Center" nor via Synaptic Package Manager.
What to do: Download JDK 7 binaries from the official Java site.
Problem 2: You are Debian/Ubuntu user and don’t see applicable .deb package.
What to do: Again, download JDK 7 self-extract binaries from the official Java site, install and configure it manually.
Step by step instructions to install and manual configure JDK 7 on the Ubuntu 10.04 LTS (the Lucid Lynx) desktop follow:
- For my X64 Ubuntu 10.04 LTS Desktop installation I downloaded Linux X64 self-extracting JDK file from Linux X64 Platform section.
- Using
chmod 755 ./jdk-7-ea-bin-b118-linux-x64-11_nov_2010.bin
command I made file executable.
- Execute it. JDK 7 package is extracted into ./jdk1.7.0 directory.
- Move JDK 7 directory to place where it should be. Right, to the /usr/lib/jvm/jdk1.7.0 directory. Use this command for that
sudo mv ./jdk1.7.0/ /usr/lib/jvm/jdk1.7.0
- Execute this command
sudo update-alternatives --config java
to know under what number you will config you new Java installation. You will get output as:
$sudo update-alternatives –config java
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
Press enter to keep the current choice[*], or type selection number:
Remember the last number and press enter to exit this utility.
- Execute this command
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java 3
to add your new JDK 7 installation into alternatives list. I put 3 there as 2 was last number for my configuration. You should use your own number from the previous step increased by 1.
- Execute this command
sudo update-alternatives --config java.
You will see output similar one below:
$sudo update-alternatives –config java
There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode
Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.
The job is done. You are fineshed. Just check version of you new JDK 7 installation typing this command java -version. You should see something like this:
~$ java -version
java version “1.7.0-ea”
Java(TM) SE Runtime Environment (build 1.7.0-ea-b118)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b02, mixed mode)

6 comments:

  1. Thanks for your instructions.

    I am only wondering:
    What are the consequences for Tomcat? Do I need Tomcat7 also and consequences for Ant?

    I have some ERP-applications installed (i.e. Opentaps). All Java6. Consequences?

    Greetings
    Frans
    f.van.der.star@gmail.com

    ReplyDelete
  2. i got
    update-alternatives: error: no alternatives for java.

    when i execute
    sudo update-alternatives --config java.

    ReplyDelete
  3. Cool!! Finally got it to work, thanks for this lovely tutorial

    ReplyDelete
  4. What about the many other commands in jdk such as jar, javadoc, etc?

    ReplyDelete