Debian 10 and Elasticsearch 7.x

Just run

sudo apt install default-jdk
BASH

Check installed Java version with

java -version
BASH

Debian 8 and Elasticsearch 5.x

The desired version of OpenJDK is not available in out-of-the-box Debian Jessie. So you have to rely on Debian Backports repository and add the following lines to the end of your /etc/apt/sources.list file: 

# jessie backports
deb http://http.debian.net/debian jessie-backports main
BASH


You can use the nano text editor:

nano /etc/apt/sources.list
BASH


The installation of version 8 is then straight forward:

apt-get update
apt-get install -t jessie-backports openjdk-8-jdk
BASH


You can also make Java 8 the default:

update-alternatives --config java
BASH

Links with more detailed information: