Installation of JAVA onĀ Ubuntu
·1 min
Table of Contents
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 #
- 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
- 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
- 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.