Ok. Let's start.
I am using Ubuntu 14.04 LTS here. First of all log in to your machine and open up a terminal window with Ctrl
Type the following line and press enter.
sudo apt-add-repository ppa:webupd8team/java
Then you will get following output. Through this you can install java 6, 7, 8 or later according to your preference.
Press Enter to continue.
Now you should download the package lists from the repositories and update them to get information on the newest versions of packages and their dependencies.
For that type : sudo apt-get update in the terminal and press enter. It will do this for all repositories and PPAs.
When it is done you are ready to install your preferred version of java.
For that type following.
sudo apt-get install oracle-java<version_number>-installer
e.g. sudo apt-get install oracle-java6-installer
The version number is 6, 7 or 8. According to that it will start the installation of java version.
Press Y to continue.
Then you will lead to the package configuration wizard. According to the java version that you have selected to install.
Agree the licence by pressing ok.
If you want you can go to http://java.com/license page and read the licence before this step.
Then it will continue the installation.
Once it is done it will direct to the directory you were in the terminal.
Done. Now you can test whether java has installed in the machine using java -version command as shown in the following image.
If you have successfully installed JAVA in your machine you will receive the shown output.
It will show java version that you have installed, Java SE Run-time Environment built and the VM built with the mode.
Lets see how you can set the java path (JAVA_HOME) in your machine in Part 2 of this post.
See you in Installing and Configuring Java in Ubuntu completely through terminal -Part 2.