How to install java on Ubuntu 14.04

How to install java on Ubuntu 14.04

Installing Java on your Linux – Ubuntu 14.04 System is not a difficult task for you. As if you want to install Java 8 or any version then it is not as difficult as you think. Linux is a Major Operating  System which most of the people ignore to use, but we should not forget that Android Operating System which are used in your Smartphones or Tablets is based on Linux.


If you use Linux Box then it is very essential to install Java on your Systems. A different method can be used for the user’s who have already installed jdk 7, but other users can also use this method to Install Oracle Java 8 on their systems. Just download the Archive file and select the alternative installation. So, lets get started on this trick:

Check out →
How to fix error of build 7600 not genuine copy in Windows 7
How To Make any Windows Volume Louder Manually
How to Play Games with a Physical Controller on Android
How to delete your Facebook account

How to install java on Ubuntu 14.04:

  • Check your current java version:
    – Use the below command to check installed java version on your Linux system.
PcName@PcName-desktop:/opt$ java -version
 java version "1.7"
 OpenJDK Runtime Environment (IcedTea 2.5.1) (7-2.5.1-4ubuntu1~0.14.04.1)
 OpenJDK 64-Bit or 32-Bit Server VM (build 24-b04, mixed mode)
  • Download oracle Java Archive File:
    – Use the below command to download the oracle java 8 archive file.
    – Make sure oracle uses cookies , so use according to that.
PcName@PcName-desktop:/opt$ sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz"
 --2013-02-23 12:12:22-- http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz
 Resolving download.oracle.com (download.oracle.com)... 123.176.32.147, 123.176.32.186
 Connecting to download.oracle.com (download.oracle.com)|123.176.32.147|:80... connected.
 HTTP request sent, awaiting response... 302 Moved Temporarily
 Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz [following]
 --2013-02-23 12:12:22-- https://edelivery.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz
 Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.57.214.140
 Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.57.214.140|:443... connected.
 HTTP request sent, awaiting response... 302 Moved Temporarily
 Location: http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz?AuthParam=1408704385_32ff25d84ee75dc59d0137c34e55e9c9 [following]
 --2013-02-23 12:13:26-- http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz?AuthParam=1408704385_32ff25d84ee75dc59d0137c34e55e9c9
 Connecting to download.oracle.com (download.oracle.com)|123.176.32.147|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 160872342 (153M) [application/x-gzip]
 Saving to: ‘jdk-8u20-linux-x64.tar.gz’
  • Extract the File:
    Use the below command to extract the tar.gz archive file.
PcName@PcName-desktop:/opt$ sudo tar -zxvf jdk-8u20-linux-x64.tar.gz
  • Installing Environment Variables of downloaded oracle java 8:
    – Use the below command to Install oracle java 8 on your system using the alternative method.

PcName@PcName -desktop:/opt$ sudo update-alternatives –install /usr/bin/java java /opt/jdk1.8.0_20/bin/java 2

  • Choose an alternative java version:
    Use the below command to list installed java version, Choose oracle java 8 Environment Variables which is installed newely on the system.
PcName@PcName-desktop:/opt$ sudo update-alternatives --config java
 There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
 ------------------------------------------------------------
 * 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
  1 /opt/jdk1.8.0_20/bin/java 2 manual mode
  2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
Press enter to keep the current choice[*], or type selection number: 1
 update-alternatives: using /opt/jdk1.8.0_20/bin/java to provide /usr/bin/java (java) in manual mode
  • Setup jar using alternative method.
PcName@PcName-desktop:/opt$ sudo update-alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_20/bin/jar 2
PcName@PcName-desktop:/opt$ sudo update-alternatives --config jar
 There are 2 choices for the alternative jar (providing /usr/bin/jar).
Selection Path Priority Status
 ------------------------------------------------------------
 * 0 /usr/lib/jvm/java-7-openjdk-amd64/bin/jar 1071 auto mode
  1 /opt/jdk1.8.0_20/bin/jar 2 manual mode
  2 /usr/lib/jvm/java-7-openjdk-amd64/bin/jar 1071 manual mode
Press enter to keep the current choice[*], or type selection number: 1
 update-alternatives: using /opt/jdk1.8.0_20/bin/jar to provide /usr/bin/jar (jar) in manual mode
  • After Selecting the alternative method, Check your java version:
    Use the below command to check your new Environment Variables java version.
PcName@PcName-desktop:/opt$ java -version
 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)

It will show you the new Oracle Java 8 as new Environment Variables on your screen.

  • Now  the final step is to Set-up the Environment Variables:
  • Use the below command lines to Setup Environment Variables because java based applications uses environment variables.
  •  You just export “JAVA_HOME, JAR_HOME & PATH”.
PcName@PcName-desktop:/opt$ export JAVA_HOME=/opt/jdk1.8.0_20/bin/java
PcName@PcName-desktop:/opt$ export JRE_HOME=/opt/jdk1.8.0_20/bin/jar
PcName@PcName-desktop:/opt$ export PATH=$PATH:/opt/jdk1.8.0_20/bin:/opt/jdk1.8.0_20/bin/jar/bin
  • Now, you have successfully did setup of the Environment Variables.
  • Use the below command to check whether its setup is done properly or not.
PcName@PcName-desktop:/opt$ echo $JAVA_HOME
 /opt/jdk1.8.0_20/bin/java
PcName@PcName-desktop:/opt$ echo $JRE_HOME
 /opt/jdk1.8.0_20/bin/jar

Your Environment Variables are ready on your Linux OS.

If you are using a 32 Bit version then you can use this command and follow all the steps.

# sudo wget –no-cookies –no-check-certificate –header “Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie” “http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-i586.tar.gz”

OR

You can visit the oracle website and download the packages.


See me

Don’t forget to Give your valuable comments..

2 Trackbacks & Pingbacks

  1. How to download online videos for free - TricksNow
  2. How to make USB as read-only - TricksNow