#Update your server
sudo apt-get update -y
sudo apt-get upgrade -y
#Apache Maven requires Java to be installed on your server. By default, Java is not available in Ubuntu's repository. Add the Oracle Java PPA to Apt with the following command:
sudo add-apt-repository ppa:webupd8team/java
#Next, update your Apt package database with the following command:
sudo apt-get update -y
#Install the latest stable version of Oracle Java 8.
sudo apt-get install oracle-java8-installer
#Verify the Java version by running the following command:
java -version
#Output:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)