Installing Oracle JDK 7 on Ubuntu 12.04

- Download Java SE 7u4 from Oracle and Uncompress it
$ tar xf jdk-7u4-linux-x64.tar.gz

- JDK 7 package is extracted into jdk1.7.0_04 directory. Move this directory to /usr/lib/jvm/
$ sudo mv ./jdk1.7.0_04 /usr/lib/jvm/jdk1.7.0_04-sun

- Now run
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_04-sun/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_04-sun/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_04-sun/bin/javaws" 1

- Set newly installed java as default
$ sudo update-alternatives --config java

- Verify version of new JDK 7 installation
$ java -version

- Repeate above steps for
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config javaws

UPDATE : Please read the update-alternatives(8) man page for information

Shamelessly copied from - http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7

About these ads

5 thoughts on “Installing Oracle JDK 7 on Ubuntu 12.04

  1. Amit Gharat

    You can make it a bit original by explaining what ‘update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/jdk1.7.0_04-sun/bin/java” 1′ and ‘update-alternatives –config java’ commands do basically.

    Reply
  2. Raj

    Would like to know if you have any thoughts about the recent Java security fiasco. Many are of the opinion that you should completely remove Java, but so many websites are still using it, it does not seem practical.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s