[https://discourse.osmc.tv/t/java-8-in-osmc/22369/8]
To enable Stretch backports and make its contents available, do something like:
echo deb http://ftp.debian.org/debian stretch-backports main | sudo tee --append /etc/apt/sources.list
sudo apt-get update
To install the JRE package, there's a special quirk:
$ sudo apt-get -t stretch-backports install openjdk-8-jre-headless
If "-t stretch-backports" is not included, it complains of a dependency problem and won't install.
After this, verify Java 8 is installed.
$ java -version
sudo apt-get install libjna-java
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8
$ sudo update-alternatives --config java
Copy the path from your preferred installation, and then open /etc/environment using nano or your favorite text editor.
sudo nano /etc/environment
In this file, add the following line, making sure to replace the path with your own copied path.
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-armhf"
Save and exit the file, and reload it with:
source /etc/environment
You can now test whether the environment variable has been set:
echo $JAVA_HOME