Running openHAB 2 on OpenJDK

I’m currently running openHAB on a headless Arch Linux system using OpenJDK as that is the JDK available through their official repositories. However, there are recommendations on these forums and in the documentation against using OpenJDK. Why is that? Apart from vague statements about OpenJDK being “less stable and slower” than the Oracle implementation, I have not seen a technical explanation as to why that is. My own independent research says OpenJDK is now the reference implementation and that there are very few differences between the OpenJDK and Oracle implementations. Does anyone have any insight?

The are parts of openHAB known to not work on OpenJDK. It is as simple as that. One thing in particular is OpenJDK doesn’t yet (as of a month ago or so) trust certs from LetsEncrypt. It indeed runs more slowly, has memory leaks, and some bindings throw weird errors when running it. I don’t remember which bindings of hand.

Based on Kai’s comments on this openhabian issue, you may also want to look at Zulu embedded

https://github.com/openhab/openhabian/issues/57

There is at least one important non-vague argument:

http://docs.openhab.org/installation/index.html#prerequisites

Oracle Java offers significant performance advantages over OpenJDK on ARM platforms, and will expand the range of Java applications that run well [on the Raspberry Pi].

It might be time to reevaluate this statement, google pointed me to these results from one year ago indicating it’s still the case.

I read the statement about ARM but kind of glossed over it because I’m running openHAB on an x86_64 machine (although I do have some Raspberry PIs, I’m not currently using openHAB on any of them). I ran openHAB 1.x without any major issues on OpenJDK but then saw the notice in the 2.0 docs about Oracle being preferable. I’m currently running 2.0 on OpenJDK and it seems to be functional for my purposes unless some of the weird issues I’ve had with PaperUI not updating Z-Wave things properly can be attributed to OpenJDK.

I appreciate the responses. When I read a statement like “openHAB may be unstable and slower executed by OpenJDK”, I tend to want facts to back it up before I blindly make changes to my system to accommodate.

Just my experiences so far!

It is not possible to run 64-bits OS Linux Mint , 32-bits JVM and 2.1.0.201701231847 Tellstick Binding.
But my serial-device(enocean) works with 64-bits OS Linux, 64-bits JVM, OpenJDK 64-Bit Server VM (build 25.111-b14.

In README.md for the Tellstick binding:
+For USB connected tellsticks only, eg. Basic and DUO

+First of all you need to make sure that your JVM is matching your installed Telldus Center. This normally means openHab must run on a 32bit JVM for windows and a 64bit JVM for linux. For windows the binding is hardcoded to look for Telldus Center in Programs Files (“C:/Program Files/Telldus/;C:/Program Files (x86)/Telldus/”). If you have trouble getting the telldus core library to work you can modify the library path using…

In http://docs.openhab.org/installation/index.html1 /Installation/Overview/Prerequisites:
Also make sure to use the 32-bit version of the JVM, even on 64-bit operating systems. Serial connections won’t work with a 64-bit JVM, so bindings like Z-Wave won’t be working with it.

I have now running like 64-bit OS Linux , 64bit JVM as abow, openhab2 Last Stable(2.1.0 snapshot Build 752), 2.1.0.201701231847 Tellstick Binding, 1.10.0.201701240211 openHAB enocean Binding,
during a week and so far is everything working as expected.
My HW is as an regular HP-Laptop, Tellstick DUO and enocean USB 300.

So it seems like there are a lot of different configuration-mixes that sometimes works and sometimes not, and in my case so had it take me some time to figure out which configuration-mix which will be the best for my needs.
But I do like this kind of work though that you then really had to learn a lot of the entire system.

My best regards to all people involved in OH2 developing , great system indeed.

I can absolutely relate to that. I could try to add a few more lines on the topic (when/if I find the time). It would be great if you could help out here!? Maybe it would be best to create a small comparison table with the three options and the different pros and cons, recommended versions, limitations…

@Basse_03 same goes for you…

FTR, there were regular reports of JVM crashes, similar to what is described here, see e.g. this report.

Wrt performance on ARM CPUs, see here.
And the performance issues on ARM are very real (afaik, this is mainly due to a missing JIT compiler) - see e.g. this report, where the startup of openHAB takes 20 minutes (and I have seen a similar behavior on a RPi2).

The good news is that Azul System now provides optimized OpenJDK builds for ARM that include JIT and seem to work as well as the Oracle JVM. For ARM computers, this is now definitely our recommendation.

… and will be stated as such in the openHAB documentation as soon as packages are available via repository.

I may just do that. There are some other gaps in the documentation that I might try to fill in as well. At this point it’s just a matter of finding the time to setup the doc repository on my machine so I can attempt to contribute. I might have some time tonight - we’ll see.

2 Likes

Well I went ahead and attempted to update the documentation:

This is my first attempt at a pull request, so hopefully I did it right. :grin:

2 Likes

Thanks again! Yes you did, now there are just a few comments :smiley:

Cool, I’ll tweak it and hopefully push a second revision later tonight.

Is adding zulu repo documented anywhere in openhab docs ?

how to add repo here

how to install zulu-embedded-8 here

what do i need to do to be able to participate in the openhab docs?

Submit an issue and/or PR to the openhab-docs github project.

Yes please.
Also @mohsh86: You are correct, we should probably replace or extend the part where we describe how to install Oracle Java here: http://docs.openhab.org/installation/linux.html - However I’m not a big fan of copying documentation from elsewhere. Hence I’d suggest to link the instructions as you did above, instead of copying them to our article. Would you agree? A PR would be highly appreciated.

So, this is a bit unclear, and it’s the go-to post from the installation page on the topic. There is a vague hint that OpenJDK is problematic, but every single actual report refers to openJDK on ARM. The OP was asking specifically about running OpenHAB 2 on an x86_64 Linux server. Are there any reports of problems with OpenJDK that aren’t related to ARM devices?

The recommendation here for running Azul’s Zulu JVM over OpenJDK is now 4 years old and predates the move to Java 11 with openHAB 3. Is there still any validity to it?

The openHAB install docs still reference this article, which is short on recent information. It seems like a good time to review this recommendation and maybe update the install docs as well (Installation Overview | openHAB).

Recently users reported issues here which could be solved by switching to Zulu 11, so this is still valid.