The are multiple flavours distributed on this page. Notably the Windows/Linux/Mac ones that do have an embedded JRE, and that’s on purpose to facilitate adoption/usage.
The Any flavour is the one that doesn’t have an embedded JRE, as clearly stated:
*This package expects that a JVM is already installed on the system - with same Java requirements as the SonarQube server.
It requires very careful reading of the full source to understand that this line:
use_embedded_jre=true
effectively disables all the following logic to figure out a suitable JAVA_HOME, including causing the existing environment variable to be ignored and overridden.
Perhaps this in-script documentation can be corrected to reflect this behaviour. The solution for me is indeed quite simple: just download the “Any” flavour. It’s just that this way it took a good amount of time to figure that out.