December 14, 2014

Install and configure latest Oracle Java JDK 8 and 7 in Ubuntu

Hi friends,

Today, I'll try to explain the way how to install the latest Oracle Java JDK 8 and 7.


Ubuntu 12.02 or above


We can install in two ways
  1. Using PPA
  2. Manual Installation

PPA installation

  • Open terminal from "Applications" or press key combination "Ctrl+Alt+T"
  • Type the following commands in sequence
    • $ sudo apt-add-repository ppa:webupd8team/java
    • $ sudo apt-get update
  • To install latest JDK 8, type the following command
    • $ sudo apt-get install oracle-java8-installer
  • To install latest JDK 7, type the following command
    • $ sudo apt-get install oracle-java7-installer
  • Once the download complete, it will ask for agree for terms and conditions
  • Click on "OK" to complete the installation

Manual Installation

  • Download the Oracle JDK from the following official link
  • Extract the downloaded zip (Example "jdk-")
  • It will create a folder with name "jdk-"
  • Create a folder "java-8-oracle" under "/usr/lib/jvm" folder
    • $ sudo mkdir -p /usr/lib/jvm/java-8-oracle
  • Move the folder contents to /usr/lib/jvm/java-8-oracle
    • $ mv jdk-* -rf /usr/lib/jvm/java-8-oracle/

Configure the java executables

Configuration can only be done if more than one JDK is installed.

To configure java execute the following command

$ sudo update-alternatives --config java

Example output if Java 7 and Java 8 installed
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                     Priority   Status
  0            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         auto mode
  1            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java   1         manual mode

Similar way you can do for javac, javaws and other executables

Configure javac

$ sudo update-alternatives --config javac

Configure javaws

$ sudo update-alternatives --config javaws

Happy java coding guys :)



Please send your feedback and comments to

Post a Comment

Featured Post

Java Introdcution

Please send your review and feedback to