Skip to main content
  1. Articles/

Installation of JAVA onĀ Ubuntu

·1 min

java

How to install Java #

Ubuntu 12.04 and earlier version uses Open JDK 6 as Default version, and Ubuntu 12.10+ versions have Open JDK 7

Multiple steps to download java #

  1. I have installed java 8. Following are the steps to download java 8 from command-line.
sudo apt-get install openjdk-8-jdk

Note: Replace 8 with 6, 7 to install JAVA 6, 7 respectively

  1. Install oracle java 8 by following command:
sudo apt-get install oracle-java8-installer

Note: Replace 8 with 6, 7 to install JAVA 6, 7 respectively

  1. Install default java for your ubuntu system by following command:
sudo apt-get install default-jdk

After installation you may check java version by “java -version” command To view java path use command “which java” How to remove existing java

sudo apt-get remove openjdk-10* (if installed java version is 10)

How to set JAVA_HOME JAVA: To set JAVA_HOME globally in ~/.bashrc, launch terminal and type following: sudo gedit ~/.bashrc (This will open the bashrc file)

At the end of the file type the following, one line at a time:

JAVA_HOME=/usr/lib/jvm/default-java/bin
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

Close the terminal and reopen it and type

echo $JAVA_HOME

You should get the new java path.