Detected JDK Version: 18.0.1 is not in the allowed range [11.0,18.0)

I try to create a new binding by running

./create_openhab_binding_skeleton.sh Rachio "Markus Michels" markus7017```

and the script aborts with

[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-java) @ org.openhab.addons.reactor.bundles **---**
[WARNING**] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 18.0.1 is not in the allowed range [11.0,18.0).
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE**
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.076 s
[INFO] Finished at: 2022-07-17T19:22:32+02:00
[INFO]------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2:enforce **(enforce-java)** on project org.openhab.addons.reactor.bundles: **Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.** -> **[Help 1]**

even Java/JDK 18 is not installed

ls -l /Library/Java/JavaVirtualMachines
total 0
drwxr-xr-x  3 root  wheel  96 18 Apr 19:46 zulu-11.jdk
drwxr-xr-x  3 root  wheel  96 19 Apr 08:11 zulu-8.jdk
java -version
openjdk version "11.0.14.1" 2022-02-08 LTS
OpenJDK Runtime Environment Zulu11.54+25-CA (build 11.0.14.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.54+25-CA (build 11.0.14.1+1-LTS, mixed mode)
jenv versions
  system
  1.8
  1.8.0.322
* 11 (set by /Users/markus/Dev/openhab-3/git/openhab-addons/bundles/.java-version)
  11.0
  11.0.14.1
  zulu64-1.8.0.322
  zulu64-11.0.14.1

Why does it detected JDK 1.18.1? How to fix this?

If you are under linux there might be a $JAVA_HOME coming into play. Depending on the distribution update-alternatives might not update it leading to situation where tools which rely on environment variable get crazy.

I am not using jenv. I know for sure maven doesn’t use it as well, so you have to find a way to link it over JAVA_HOME. I use for that purpose direnv which is more generic.