Guide to install Java and latest Eclipse on Ubuntu 14.04

There are several implementations of Java available. Openjdk, Oracle and Sun (Old Java).
Here I will post how to install Openjdk and Oracle implementation of Java.
You require to install any one of them.

Installing Openjdk 7

Open Terminal with Ctrl + Alt + T

sudo apt-get update
sudo apt-get install openjdk-7-jdk

If you want the source code of Java use

sudo apt-get install openjdk-7-source

For only runtime environment

sudo apt-get install openjdk-7-jre

Installing Oracle Java 7 & 8

We have to use a third party PPA

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update

For Java 7

sudo apt-get install oracle-java8-installer

For Java 8

sudo apt-get install oracle-java8-installer

And you are done installing Java!!

Installing java plugin for browser

sudo apt-get install icedtea-plugin
If you have multiple versions of Java then configure the default one with

sudo update-alternatives --config java

Now check the version of Java

java -v

Installing latest Eclipse on Ubuntu 14.04

The Eclipse packages in Ubuntu are are very out of date.
The following method will install latest eclipse
1) Download Eclipse from

http://www.eclipse.org/downloads/

2) Extract it

tar xzf eclipse-jee-indigo-SR2-linux-gtk.tar.gz

3) Move to /opt/ folder

mv eclipse /opt/
cd /opt/
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse

4) Create an eclipse executable in your path

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudo gedit /usr/bin/eclipse

5) copy this into eclipse

#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*

6) create a gnome menu item

sudo gedit /usr/share/applications/eclipse.desktop

copy this………

Desktop Entry
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true

7) Launch Eclipse for the first time

/opt/eclipse/eclipse -clean &

Congrats!! eclipse is installed.