Migrating from 3.4.0 to 4.0.0

This is where you may benefit from openhabian on a Pi.

This is written many times in the docs. openHAB is written in Java, so it has a natural Java dependency.
It is also mentioned many times that openHAB 2 needed Java 8, openHAB 3 Java 11 and openHAB 4 needs Java 17.