Categories: UbuntuUbuntu 12.04

How to install Oracle java 7 on ubuntu 12.04

By default ubuntu 12.04 comes with Openjdk. In this article, we can see how to install Oracle java 7 on ubuntu 12.04.

Installing Oracle java 7 on ubuntu 12.04

Step 1 » Check the version of java package installed by issuing the below command
krizna@leela:~$ sudo update-java-alternatives -l
java-1.7.0-openjdk-i386 1051 /usr/lib/jvm/java-1.7.0-openjdk-i386

[OR]
krizna@leela:~$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

The results shows openjdk is installed on your machine .

Step 2 » Remove openjdk by typing the below command .
krizna@leela:~$ sudo apt-get purge openjdk*
Step 3 » Issue the below command to add webupd8 repository.
krizna@leela:~$sudo add-apt-repository ppa:webupd8team/java
Step 4 » update the repositories
krizna@leela:~$sudo apt-get update
Step 5 » Now install Oracle java7 by issuing the below command.
krizna@leela:~$ sudo apt-get install oracle-java7-installer
Step 6 » That’s it, Now check the version
krizna@leela:~$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode)

[OR]
krizna@leela:~$ sudo update-java-alternatives -l
java-7-oracle 1 /usr/lib/jvm/java-7-oracle

Oracle Java7 is installed on ubuntu 12.04.

Troubleshooting

Is you had any problem installing the updated version, just remove all the installed java versions and try installing again.
» Just issue the below command to check the installed java versions.
krizna@leela:~$ sudo update-java-alternatives -l
java-1.7.0-openjdk-i386 1051 /usr/lib/jvm/java-1.7.0-openjdk-i386
java-7-oracle 1 /usr/lib/jvm/java-7-oracle

Here we can see both Openjdk and Oracle java installed, we need to remove both inorder to perform a clean install .
» Issue the below commands one by one to remove other versions of java.
krizna@leela:~$ sudo apt-get purge openjdk*
krizna@leela:~$ sudo apt-get purge icedtea*
krizna@leela:~$ sudo rm /var/lib/dpkg/info/oracle-java7-installer*
krizna@leela:~$ sudo apt-get purge oracle-java7-installer*
krizna@leela:~$ sudo rm /etc/apt/sources.list.d/*java*
Reboot the machine and continue from Step 3 to install Oracle java latest version.

Disqus Comments Loading...
Share
Published by
krizna

Recent Posts

How to install Visual Studio Code on ubuntu 20.04

Visual Studio Code is a popular code editor which is lightweight and cross platform application.…

4 years ago

How to install MySQL workbench on ubuntu 20.04

MySQL workbench is a GUI tool for managing MySQL database system. It is used by…

4 years ago

How to install Android Studio on ubuntu 20.04

Android Studio is a popular development software used especially for developing android applications. It is…

4 years ago

How to install google chrome on ubuntu 20.04

Google chrome is a most popular web browser developed by google. It was developed to…

4 years ago

How to install Zoom on ubuntu 20.04

Zoom is a popular video conferencing software. It is commonly used for conducting online meetings,…

4 years ago

How to install TeamViewer on ubuntu 20.04

TeamViewer is a popular application for desktop sharing and remote control. It is available for…

4 years ago