Install openjdk8
Execute the following commands in order
sudo apt-get update
sudo apt-cache search openjdk

Note: Select any suitable package from the top. This documentation selects the openjdk-8-jdk
sudo apt-get install openjdk-8-jdk
Prepare your system for jenkins in ubuntu
Execute the following commands
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list sudo apt-get update
Before executing install of jenkins lets try to find the possible jenkins versions available
sudo apt-cache madison jenkins

Note: In this documentation 2.138.3 will be used
Installing Specific Version of Jenkins
sudo apt-get install jenkins=2.138.3 -y
Note: Follow this steps to install any LTS version of jenkins