How to install Java JDK and JRE on a Raspberry Pi and Pi Zero in 2020

  java, linux, raspberry-pi

You need to install JDK8 because JDK11 and others won’t work. 

Otherwise, you’ll get errors like this one:

Server VM is only supported on ARMv7+ VFP

Install:

sudo apt-get install openjdk-8-jre-headless openjdk-8-jdk-headless

Verify:

root@door:/home/pi/programs/doorswitch# javac -version
javac 1.8.0_212


root@door:/home/pi/programs/doorswitch# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1+rpi1-b01)
OpenJDK Client VM (build 25.212-b01, mixed mode)