openHAB 5.x-SNAPSHOT requires Java 21

Hi everybody,
this is to make you aware that we have already switched the OH 5.0.0 snapshot builds to Java 21.
Starting tomorrow, you will need Java 21 to run openHAB 5.

Please keep in mind that we will also switch to 64 bit for OH5 and stop creating 32-bit images etc.
See the release note of OH 4.3 for more information.

And as every time when we release a new stable version: If your are in the middle of developing a PR, also keep in mind to rebase to our latest commit on the main branch.
Thanks!

8 Likes

I still have questions on this. I expect to still be fixing things in 4.3 addons. So far, one would mostly be able to use the new snapshot compiled jar in the previous release version of the software when manually installing.
Does this mean if I use the standard development setup my compiled addon jars will not work in the previous version? How do I make sure they do work in the 5.0.0 snapshot as well as in the 4.3 release core?

1 Like

For us (developers), I assume we need to have both Java 17 and Java 21 JDK installed on dev PC. We can then switch between Java 17 and Java 21 JDK depending on if we want to build a jar to be used in 4.3.x or 5.0.

Deploying a 5.0.0-SNAPSHOT binding to 4.3 release instance can be done (as long as there are not breaking API changes) as follows:

You need a Java 21 compiler, no need for a Java 17 compiler.

  1. Run your 4.3 instance on Java 21. OH 4.3 perfectly runs on Java 21 as well. openHABian-config can be used to switch to Java 21 on RPI. Keep in mind that the future-proof setup is a 64-bit system, at some point in time a binding might require a 64-bit system. OH5 bindings compiled for Java 21 can be deployed just as usual.
    or
  2. Keep your 4.3 instance running on Java 17. Use Java 21 to compile your binding, but generate Java 17 code. We have a profile j17 in place in the addons repo to do this without modifying the pom file: mvn install -Pj17 -Dohc.version=4.3.0. This will only work for bindings which do not require specific Java 21 libraries or features. Same remark as above: Keep in mind that the future-proof setup is a 64-bit system, at some point in time a binding might require a 64-bit system. IDEs might need some tweaking, otherwise you might end up with some Java 21 classes in the target folder.

tl;dr:
Run openHAB 4.3 on a 64-bit system with Java 21 if you want to use 5.0.0-SNAPSHOT bindings.

3 Likes

The Docker images are now updated for this and OH5 seems to start. :whale:
Let us know if something is broken due to Java 21!

2 Likes

I’m probably not doing this correct (many errors). I did mvn clean install with Java 21, then ran mvn install -Pj17 I’m using windows 11 with github desktop. Also have been going directly to the binding folder to compile C:\Users\Robert\GitHub\openhab-addons\bundles\org.openhab.binding.mideaac>mvn install -Pj17
Do I need to switch java versions for this work? Partial log

[ERROR]         mvn:org.ow2.asm/asm/9.7
[ERROR]         mvn:org.threeten/threeten-extra/1.8.0
[ERROR]         mvn:org.yaml/snakeyaml/2.2
[ERROR]         mvn:si.uom/si-quantity/2.1
[ERROR]         mvn:tech.units/indriya/2.2
[ERROR]         mvn:tech.uom.lib/uom-lib-common/2.2
[ERROR] }
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

C:\Users\Robert\GitHub\openhab-addons\bundles\org.openhab.binding.mideaac>java -version
java version "21.0.4" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 21.0.4+8-LTS-274)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.4+8-LTS-274, mixed mode, sharing)

Did you rebase?

Does it mean that Java 21 is not considered experimental or untested anymore for 4.3?

For me it seems to be stable. I have been running Java 21 on my dev setup an did not encounter any problems. The last Java17/21 issue I can think of was the persistence issue due to the UTF8 character in date strings - which has been dealt with months ago. Our unit tests and integration tests also work well.

Cannot tell how many people use Java 21, but I think it is fine to do so. I have not seen bug reports.

1 Like

I’ve updated both my 4.3 instances to Java 21 a couple of days ago and have seen nothing unexpected.

I did yesterday, but I’m not at the computer right now. I’m up to 2 commits that talk about oh 5. I did create a jar that works on the OH5 snapshot . Will check

Edit I have up to your #17910 PR. I don’t have 17914, is that related?

don’t know if this helps, but it appears to choke at the karaf 4.4.6 verify when I add -Pj17.
build logs.txt (2.4 KB)

@apella12 Could you try if adding ** -Dohc.version=4.3.0 -Pj17 ** resolves this problem?

That worked to compile :smile: Thanks

I’ll still have to test if the jar works in my OH4.3 instance. Will post update when I get that done. A little busy right now

Edit: Also confirm the compiled jar works with OH4.3 and Java 17. All good.

I can confirm this was the missing piece. I was able to build an OH 5.0.0 snapshot binding and run it on OH 4.3 and Java 17.

i have massive issues with docker and the 5.0 snapshot.
My logs are getting flooded and in portainer OH is stuck “starting”.
If i filter the log for “error” i get this:

2025-01-02 22:58:59.981 [ERROR] [xtext.validation.CompositeEValidator] - Error executing EValidator

2025-01-02 22:59:00.236 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment ‘|::0.2.0.2.0.0.0::0::/1’ failed.

2025-01-02 22:59:00.476 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment ‘|::0.2.0.2.0.0.0::0::/1’ failed.

2025-01-02 22:59:12.475 [ERROR] [xbase.resource.BatchLinkableResource] - resolution of uriFragment ‘|::0.2.0.2.0.0.0.6.6::0::/1’ failed.

the rest looks like this:

                      JvmField: Tmp_TVRules.Hobby_Helligkeit (visibility: PRIVATE, simpleName: Hobby_Helligkeit, identifier: Tmp_TVRules.Hobby_Helligkeit, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> NumberItem
                      JvmField: Tmp_TVRules.SprinklerZone3 (visibility: PRIVATE, simpleName: SprinklerZone3, identifier: Tmp_TVRules.SprinklerZone3, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> GroupItem
                      JvmField: Tmp_TVRules.Arbeitszimmer_Echo_Volume (visibility: PRIVATE, simpleName: Arbeitszimmer_Echo_Volume, identifier: Tmp_TVRules.Arbeitszimmer_Echo_Volume, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> DimmerItem
                      JvmField: Tmp_TVRules.SprinklerZone4 (visibility: PRIVATE, simpleName: SprinklerZone4, identifier: Tmp_TVRules.SprinklerZone4, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> GroupItem
                      JvmField: Tmp_TVRules.SprinklerZone1 (visibility: PRIVATE, simpleName: SprinklerZone1, identifier: Tmp_TVRules.SprinklerZone1, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> GroupItem
                      JvmField: Tmp_TVRules.Arbeitszimmer_Nanoleaf_Power (visibility: PRIVATE, simpleName: Arbeitszimmer_Nanoleaf_Power, identifier: Tmp_TVRules.Arbeitszimmer_Nanoleaf_Power, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> SwitchItem
                      JvmField: Tmp_TVRules.SprinklerForecastDay3Wind (visibility: PRIVATE, simpleName: SprinklerForecastDay3Wind, identifier: Tmp_TVRules.SprinklerForecastDay3Wind, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> NumberItem
                      JvmField: Tmp_TVRules.SprinklerZone2 (visibility: PRIVATE, simpleName: SprinklerZone2, identifier: Tmp_TVRules.SprinklerZone2, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> GroupItem
                      JvmField: Tmp_TVRules.OG_Flur_Fenster_Kontakt (visibility: PRIVATE, simpleName: OG_Flur_Fenster_Kontakt, identifier: Tmp_TVRules.OG_Flur_Fenster_Kontakt, deprecated: <unset>) (static: true, final: false, volatile: false, transient: false, constant: <unset>, constantValue: null) -> ContactItem
                      JvmField: Tmp_TVRules.WP_Warmwasser_Isttemperatur (visibility: PRIVATE, simpleName: WP_Warmwasser_Isttemperatur, identifier: Tmp_TVRules.WP_Warmwasser_Isttemperatur, deprecated: <unset>) (static: true, final: false, volatile: false

@holgerf I think many of the develops are facing this issue (supporting OH 4.3 while moving on with 5.0).

Wouldn’t it make sense to create a step-by-step install guide to have a “bi-lingual” setup for Dev. purposes

  • which Eclipse version
  • what to add/update
  • P17 install, options to add
  • build process to create both versions

This would be really appreciated.