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.

Pre-requisites

Ubuntu 12.02 or above

Procedure

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-1.8.0.25.tar.gz")
  • It will create a folder with name "jdk-1.8.0.25"
  • 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-1.8.0.25/* -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 :)

References

  1. http://askubuntu.com/questions/121654/how-to-set-default-java-version
  2. http://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04
  3. http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre

Please send your feedback and comments to psrdotcom@gmail.com

No comments:

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com