How did I install OpenJDK 1.8 for Elasticsearch 6 to Debian 9?

Step 1

aptitude install default-jre
aptitude install default-jdk

Step 2

update-alternatives --config java

You will got a path to your Java.
Add it to the /etc/environment file:

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"

Step 3

source /etc/environment

digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-debian-9

See also: How did I install Oracle Java 13 for Elasticsearch 6.8 to Debian 10?