How to install java in ubuntu

Hi All,In this post I will tell you how to instll the java on linux/ubuntu system. Many new user feel difficulty to install java on linux system.In this post I will tell you some easy steps to install java on ubuntu/linux. 

Note: The following command is tested on bash shell.

1. First step is to check the bit version of your linux/ubuntu operating system
    by typing the following command on your teminal-

            $ uname -a

If the output of commnad is like-

Linux pointer 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 i686 i686 i386 GNU/Linux

Then you have 32bit version of ubuntu.

And if the output of command somethin like-

Linux pointer 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Then you have 64-bit version of ubuntu.

2. Then download the tar ball ofyour java version according to your bit version(32 bit vesion 0r 64 bit version of java) of os

from the given url-

3.Extract the java using the command

$ tar -xvzf/Download/jdk1.7.0_25.tar.gz -C /usr/local

//change the location of ~/Download/jdk1.7.0_25.tar.gz from your downloaded location of java.

4.Then set the location of bin directory of java to PATH environment variable. This step is necessary to make command (java ,javac, javadoc and so on,) executables from any directory without having to type the full path of commnd,otherwise you will have to write full path to access these command like-

$ /usr/local/jdk1.7.0_25/bin/java

To set the path type the following command on terminal-

sudo gedit /etc/environment

And add the the path of bin directory like


5.Set JAVA_HOME variable in /etc/profile file.

$ sudo gedit /etc/profile

Add the following line at the and of the file,


6. Source the file /etc/profile and /etc/environment to make change effective
      $  source /etc/profile 

     $ source /etc/environment  

7. Now type java and javac command from any directory to check weather java is succesfully install or not.

Tags: Installing java on linux/ubuntu,how to install java in ubuntu,how to install java 8 on ubuntu,ubuntu install oracle java,ubuntu install openjdk 8,how to install java in ubuntu using terminal,download java for ubuntu,sudo apt-get install oracle-java8-installer,sudo add-apt-repository ppa:webupd8team/java,unable to locate package oracle-java8-installer

Leave a Reply

Your email address will not be published. Required fields are marked *