Ubuntu – how to install jdk 8 in ubuntu 12.04 using tar.gz file

Ubuntu

How can I install jdk 64-bit on ubuntu 12.04 or 14.04 LTS?

I have downloaded jdk-8u20-linux-x64.tar.gz from oracle website, as I am new to ubuntu, I need an easy way to install jdk, any body Help if possible.

please write the installation step by step, and please do not leave any link to other website, thank your for your help.

Best Answer

If you want the easy route to installing and updating Oracle Java 8(including the JRE, JDK and plugins for browsers) on Ubuntu 12.04 (or later) then I recommend doing it this way. First delete the file you downloaded as it isn't needed and proceed with these instructions:

Open a Linux terminal (command prompt) and issue these commands:

sudo add-apt-repository ppa:webupd8team/java

This will add a repository where developers place updated version of Oracle Java 8 in a format easily installed by Ubuntu package managers. When running that command it may (or may not prompt) you for your password. If it asks for a password enter your user account password. After it runs it will display information and then prompt you to hit Enter. Hit enter key to continue. You should be back at a shell prompt. Now issue these 2 commands:

sudo apt-get update

You will be prompted "Do you want to continue?". Hit y and enter When completed it will return to the shell prompt. Now issue this command:

sudo apt-get install oracle-java8-installer

This will download Oracle Java 8 and install it. Information will scroll past on the screen but when finished java should be installed. I did verify on my system that this repository is up to date and using the version of Oracle Java 8 referenced in your question.

To verify that Oracle Java 8 can be found and is the right version issue this command:

java -version

It should respond with information pretty similar to this:

java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

If yours shows the SE Runtime as build 1.8.0_20-b26 then you are good to go.

If in the future you do a package upgrade (through the GUI or command line) it will look for a new version of Oracle Java along with all the other installed packages on your system.

From the command line you can always attempt to do an upgrade on all packages (including Oracle Java) with this command:

sudo apt-get upgrade

If you ever wish to remove Oracle Java 8 you can use this command:

sudo apt-get remove oracle-java8-installer