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.

1 Like

Hi,

i get a similar error

$ java -version
openjdk version "18" 2022-03-22
OpenJDK Runtime Environment (build 18+36-2087)
OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing)


Detected JDK version 18 (JAVA_HOME=C:\Program Files\tools\jdk-18) is not in the allowed range [17.0,18.0)

I also tried to use 18.0.2 but it showed:

$ java -version
openjdk version "18.0.2" 2022-07-19
OpenJDK Runtime Environment (build 18.0.2+9-61)
OpenJDK 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing)


Detected JDK version 18.0.2 (JAVA_HOME=C:\Program Files\tools\jdk-18.0.2) is not in the allowed range [17.0,18.0).

my guess is that “18.0.2” is not “18.0” and “18” is also not “18.0”.
But how can i install exactly “18.0” since the version string does not state this?

OH is yet only compatible with Java 17, not Java 18. That is what the error message is saying.

1 Like

ah. i thought allowed range is 17.0 and 18.0

i was aiming for the “18.0” but had “18.0.2”…

but the 17.0 is allowed and i have 18.0 was not the info i gathered from that error message.

thank you for the hint!

now i get a step further… and i will try at home… out firewall blocks the download :wink: