Saturday, February 4, 2012

Ubuntu 11.10 - Installing Java 7


Download Java SE SDK from java.oracle.com website.  In my case, I needed to download 32 bit version of Linux. Hence I used this link:  http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-i586.tar.gz

I downloaded this /tmp directory.

Extract the files first;

Execute this from the ubuntu terminal shell:  sudo tar -zvxf  jdk-7u2-linux-i586.tar.gz
It creates a directory called jdk1.7.0_02 (This could be different based on the version you download).

Now we need to link it at proper place in ubuntu. First move the jdk into /usr/lib/jvm directory

Execute this from Ubuntu shell :  sudo mv jdk1.7.0_02 /usr/lib/jvm

Make the ubuntu know about this java: 

First check if there is any java jdk installed before.
Execute this command from ubuntu shell:  sudo update-alternatives --config java

Above command will list down currently installed java versions and their priorities.  In my case, there were no previous installations of java.

Execute this command from ubuntu shell to make this java known to Ubuntu:  sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_02/jre/bin/java 1

Above command not only creates a symbolic link at /usr/bin/java and also informs the software manager of ubuntu of the package name "java".   Since it is my first installation of java in this machine,  I gave priority 1 to above command.

Verification;

Check the java installation by executing following commands at shell:
sudo update-alternatives --config java
Above command should show the java you have just installed.

Finally execute following to ensure that the version you see is the one you  have just installed
java -version
Above command prints the java version.


No comments: