Step 1 To start with first we have to download the compressed binary file for your architecture. I am using 32bit OS so i will be downloading 32bit package of JDK. You can download the packages from here.

Step 2 Now uncompress it

tar -xvf jdk-7u2-linux-i586.tar.gz

Step 3 JDK 7 package is extracted into ./jdk1.7.0_02 directory. Now move the JDK 7 directory to /usr/lib

sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0

Step 4 Now run

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1

Step 5 Now run following command to change java path

sudo update-alternatives --config java

You will see output similar one below. Choose the number of jdk1.7.0. For example 3 in this list:

$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.

Step 6 Check the version of you new JDK 7 installation:

java -version
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)

Step 7 Repeat the above for:

sudo update-alternatives --config javac
sudo update-alternatives --config javaws

Step 8 Enable mozilla firefox plugin:
32 bit:

ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/

64 bit:

ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
Install the Oracle Java JDK 7 on Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recommend on Google