1#Update repo
2sudo apt update
3
4# Install java 8 from ubuntu repo
5sudo apt install openjdk-8-jdk -y
6
7#Set JAVA_HOME Path
8ls /usr/lib/jvm/java-8-openjdk-amd64/
9 export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
10 echo $JAVA_HOME
11
12 #Add JAVA bin directory to the PATH variable
13 export PATH=$PATH:$JAVA_HOME/bin
14 echo $PATH
15 java -version
1sudo gedit /etc/profile
2#add following lines
3
4JAVA_HOME=/usr/lib/jvm/{your jdk path}
5PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
6export JAVA_HOME
7export JRE_HOME
8export PATH
9#logout to update the changes