RSS

How to Install Oracle Java 8 on Ubuntu 12.04 Linux

12 May

Abstract

This blog entry will guide you through the step-by-step installation of Java on Ubuntu. I selected Oracle Java 8 and Ubuntu Linux 12.04 LTS 32 bit for this post.

Introduction

Installing Java on Linux follows the download-extract-configure pattern. We will begin by downloading Oracle Java from Oracle’s website, extracting the download in the appropriate folder, and finally informing Ubuntu about the newly installed version of Java.

Step 1: Verify that you do not already have the correct version of Java installed.

Open your console window and enter the following command:

1
java -version

If you get the following result, you already have Java 8 installed and can ignore the rest of the steps:

1
2
3
java version 1.8.0
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25-b70, mixed mode)

Step 2: Download Oracle Java.

New release of Java are featured on the main Java download page.
If Java Java 8 is no longer featured, you can find the download by following the Previous Releases link found on the main download page.
Open the Java download page in your browser and download jdk-8-linux-i586.bin.
Make a note of the folder to which you downloaded the file. For further reference in this blog, I will call this folder the “downloads folder”.

Step 3: Create the installation folder.

The /usr/lib/jvm is the default installation location of the Java JDK. Enter the following command in your console to create this folder, if it does not already exist:

1
sudo mkdir -p /usr/lib/jvm

The –p option ensures that all folders in the mkdir path are created.

Step 4: Navigate to the “downloads folder”.

If you downloaded the file to your Home folder, you can use the following command:

1
cd ~/

or substitute "~/" with the path to the “downloads folder”.

Step 5: Move the downloaded archive to the installation folder.

1
sudo mv jdk-8-linux-i586.tar.gz /usr/lib/jvm /usr/lib/jvm

Step 6: Navigate to the “installation folder”.

1
cd /usr/lib/jvm

Step 7: Unpack the tarball archives.

1
sudo tar zxvf jdk-8-linux-i586.tar.gz

If you want to conserve space you may delete the tarball archives.

1
sudo rm jdk-8-linux-i586.tar.gz

Step 8: Display the contents of the installation folder.

1
ls -l

Response:

1
jdk1.8.0

Make a note of the newly created folder names.

Step 9: Inform Ubuntu where your Java installation is located.

1
2
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1

Step 10: Inform Ubuntu that this is your default Java installation.

1
2
sudo update-alternatives --set "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac"
sudo update-alternatives --set "java" "/usr/lib/jvm/jdk1.8.0/bin/java"

Step 11: Update your system-wide PATH.

Edit your /etc/profile file using:

1
sudo nano /etc/profile

Add the following entries to the bottom of your /etc/profile file:

1
2
3
4
JAVA_HOME=/usr/lib/jvm/jdk1.8.0
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Save your /etc/profile file using CTRL + X.

Step 12: Reload your system-wide PATH.

1
. /etc/profile

Step 13: Test your new installation.

1
java -version

Note there is only a single dash before version.
Response:

1
2
3
java version 1.8.0
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25-b70, mixed mode)
1
javac -version

Note there is only a single dash before version.
Response:

1
javac 1.8.0

Step 14: Congratulations! You have just installed Oracle Java on Ubuntu Linux!

 
Leave a comment

Posted by on May 12, 2014 in Install Java 8

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
The Code is True or False

блог за integer-ите и хората

Doncho Minkov

Doncho Minkov Blog

Блогът на Васил Василев

Place for Beginner Tips and Pro Mistakes

Asen's Software Blog

blog for c# & web programing

AniSoft Blog

blog for creative developers

The Daily Post

The Art and Craft of Blogging

The WordPress.com Blog

The latest news on WordPress.com and the WordPress community.

%d bloggers like this: