I installed Java (Zulu build 9.0.0.15+181), but OpenHAB does not find it when I start the start.sh-file in Terminal.
This is the text from Terminal:
Last login: Thu Oct 5 19:24:35 on ttys000 Sindres-MacBook-Air:~ sindredidriksen$ java -version openjdk version “9.0.0.15” OpenJDK Runtime Environment (Zulu build 9.0.0.15+181) OpenJDK 64-Bit Server VM (Zulu build 9.0.0.15+181, mixed mode)
_Sindres-MacBook-Air:~ sindredidriksen$ /Users/sindredidriksen/Documents/openhab-2/start.sh _ Launching the openHAB runtime… Unable to find any JVMs matching version “1.8”. Java 1.8 or higher is required. Aborting launch.
Does anyone know what I am doing wrong or if this issue has been resolved in another thread? I am using High Sierra om my Mac.
@Kai sorry to bother you, but this is happening more often. People try with their latest JVM on their platforms and get into trouble. On ARM they try 64bit, on desktops (win/mac/lin) they try JDK10 or openJDK, all of which lead to basic issues.
Can we get an OK from Zulu Systems to distribute their JVM as part of our distribution?
Agreed. But whats happening is the incompatible Java 9/10/openJDK, doesn’t fail outright with our dist. It fails at a tricky place and everyone spends time wondering if its a legitimate issue. Perhaps a warning on UI, like the one we show when OH instance is exposed publicly because of router config.
Good point, the version should be checked by the start scripts as well.
I found this piece here, which claims to check for Java >=1.6 (while I do not find anything how it performs this check). But somewhere around there, we should change the check to ==8.
Would be great if you’d find the time for that (and have the skills ).
Yes, it should imho stop the boot, just the same way as when the JVM isn’t found at all - this code is here and I guess that’s also the best place to implement the version check.
Sure, Kai. Thanks for the pointers. I can manage shell.
We may have “tiny” little maintenance to do when fast forwarding to new karaf scripts. But I will be here, always.
The function is in the inc file which is included from the Karaf distribution.
checkJvmVersion() {
VERSION=$("${JAVA}" -version 2>&1 \
| egrep '"([0-9].[0-9]\..*[0-9]).*"' \
| awk '{print substr($3,2,length($3)-2)}' \
| awk '{print substr($1, 3, 3)}' \
| sed -e 's;\.;;g')
if [ "x${VERSION}" = "x" ]; then
VERSION=90
fi
if [ "${VERSION}" -lt "80" ]; then
die "JVM must be greater than 1.8"
fi
}
I think the best thing to do would be to override it in the setenv script. (So that it kills it on >=90?)
I confirm, the suggested fix works. OH service doesn’t start. But it goes into an auto-restart loop. Because we specified that in systemd service desc.
systemctl status openhab2.service does report exit status 1 (failure).
However its not easy for a newbie to figure out the issue.
He’s gotta go check journalctl and this line is there
karaf[26745]: Found JVM 80. JVM must be 1.7
Note that, for testing, I changed required JVM to 70 since I have JDK8 installed and didn’t want to install JDK10.
So here would be the fix in runtime/bin/inc file (/usr/share/openhab2/runtime/bin/inc on debian package based setups)
checkJvmVersion() {
VERSION=$("${JAVA}" -version 2>&1 \
| egrep '"([0-9].[0-9]\..*[0-9]).*"' \
| awk '{print substr($3,2,length($3)-2)}' \
| awk '{print substr($1, 3, 3)}' \
| sed -e 's;\.;;g')
if [ "x${VERSION}" = "x" ]; then
VERSION=90
fi
if [ "${VERSION}" -ne 80 ]; then
die "Found JVM $VERSION. JVM must be 1.8"
fi
}