Search This Blog

Saturday, October 8, 2011

Install JDK 7 on ubuntu 11

Install JDK 7 on ubuntu 11

1. download jdk binary from
http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. unzip the file (assume that the file was downloaded and saved under /home/merlin/Downloads/)

3. move the unzipped folder to /usr/lib/jvm
sudo mv /home/merlin/Downloads/jdk1.7.0/ /usr/lib/jvm/jdk1.7.0

4. find out how many jdk has been installed in the system.
sudo update-alternatives --config java

my system only had java6 installed, so the out put looks like this.

There is only one alternative in link group java: /usr/lib/jvm/java-6-openjdk/jre/bin/java
Nothing to configure.

5.  since i only had 1 installed, i'm going to install number 2 so i can pick from a list of them.
sudo update-alternatives --install /usr/bin/java java  /usr/lib/jvm/jdk1.7.0/jre/bin/java 2

-- the final number of the command is 2 meaning i'm installing second java version. if you want to install 3rd, or 4th or 5th, then the number should change accordingly eg 3, 4 or 5


6. pick your java version
sudo update-alternatives --config java

--out put from the console below


  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/jdk1.7.0/jre/bin/java         2         manual mode

0 indicates the version in use.

all you have to do now is type the number you wish to pick and hit enter

2    --- type 2 and press enter



7. test your java version

java -version

output below

java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)



done








No comments:

Post a Comment