Installing Java on Ubuntu 14.04

Java is a technology originally developed by Sun Microsystems, and acquired by Oracle. Oracle JAVA, Open JDK, IBM Java, GNU compiler are the prevalent implementations.

Installing Java with apt-get is easy. First, update the package index:

Then, check if Java is not already installed:

If it returns “The program java can be found in the following packages”, Java hasn’t been installed yet, so execute the following command:

After you run the above code it sets up everything.

Installing Oracle JDK (optional)

If your going to use android studio it will recommend you use Oracle JDK because this is official JDK.

In order to install this.

For Oracle JDK 6

For Oracle JDK 7

For Oracle JDK 8

Install any one of these. After installing java we need to set the Environment Variables as JAVA_HOME. In order to set the env. Execute following code.


When you enter the code if you have only installed one then it will show you like this otherwise it will show you list of installations. You can choose anyone you like if you have choices.

Setting Up JAVA_HOME

Now, for setting up environment variables you need to first find the path where your Java is installed. When we ran the code sudo update-alternatives –config javac we got a path like: /usr/lib/jvm/java-7-oracle/bin/javac copy this path and do the following on terminal.

Now, running this code will give you following screen.


In this file, add the following line just like shown in the picture.

We have setup the variables. In order to check refresh the file using source /etc/environment and execute

If this runs, we have succesfully setup JAVA.


In a world without walls and fences, who needs windows and gates ? No gates, no windows bt apache inside! #dev Love for #Unix #Linux #Apple. Interests in coding, music, creative design, Linux and Apple products.

You may also like...

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.