INSTALLING JAVA IN UBUNTU



This post explains how to install Java in Ubuntu. You can install Iced tea java (open source) or the Oracle java. Installing Iced tea java is simple where as to install Oracle java you have to struggle a little with the command line.
Let's get started. First I'll tell you how to install iced tea java and then we'll see how to install oracle java.

1. INSTALLING ICED TEA JAVA:

Open a terminal by pressing CTRL + ALT + T keys or by searching for “terminal” in dash. Type the following to installed iced tea java on your machine.

sudo apt-get install openjdk-7-jre icedtea-plugin


That should install the java run time environment and the plugin for your browser.

2. INSTALLING ORACLE JAVA:



To install oracle java you should first download the 32bit or 64bit Linux "compressed binary file" - it has a ".tar.gz" file extension. Now we need to uncompress the file. Right click on the file and select “extract here”. OR you can do it the terminal way:

tar -xvf jre-7-linux-i586.tar.gz

The package is now extracted into a folder. Now move the folder to
/usr/lib.

       
sudo mv ./jre1.7.0* /usr/lib/jvm/jre1.7.0




After that run the following to get a list of currently installed java alternatives:

       
sudo update-alternatives --config java


You will get the output as something like this:
       
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:





Now type the following in the terminal:

       
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 3






This will add your new java installation into alternatives list.
Now configure java to use oracle JRE:

       
sudo update-alternatives --config java





You will see output similar to the one below:

       
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/jre1.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/jre1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.


If there was no previous java installation then the new JRE will be the default and you will see output as:

       
There is only one alternative in link group java: /usr/lib/jvm/jre1.7.0/bin/java

Nothing to configure.




Check the version of your new java installation by typing the following in terminal:

       
java -version






It should produce an output similar to the one below:

       
java version "1.7.0_25"

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)

Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)




INSTALLING FIREFOX JAVA PLUGIN:

In a terminal :

       
mkdir ~/.mozilla/plugins







Now remove a former version of the Java plugin (may or may not be present)
       
rm ~/.mozilla/plugins/libnpjp2.so



Now you can install the plugin, by creating a symbolic link (you tell Firefox, where the plugin is located). For 32bit java use
       
ln -s /usr/lib/jvm/jre1.7.0/lib/i386/libnpjp2.so ~/.mozilla/plugins/


For 64bit java use :

       
ln -s /usr/lib/jvm/jre1.7.0/lib/amd64/libnpjp2.so ~/.mozilla/plugins/





Finally, installation completed successfully!

Popular posts from this blog

INSTALLING MOBILE PARTNER IN LINUX

How to setup a wifi-hotspot in Ubuntu: The terminal way.

Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?