openHAB 2 fails to start using systemctl

Hello I am interested in using openHAB for home automation, I have a raspberry PI 3 and I am intending to run Z wave devices. I have done the repository installation of openHAB 2 and I cannot get it to start using:-

sudo systemctl start openhab2.service

i get this from the log:-

Oct 29 08:38:43 homeauto_pi start.sh[3999]: Launching the openHAB runtime…
Oct 29 08:38:43 homeauto_pi start.sh[3999]: Java 1.8 or higher is required. Aborting launch.
Oct 29 08:38:43 homeauto_pi systemd[1]: openhab2.service: main process exited, code=exited, status=1/FAILURE
Oct 29 08:38:44 homeauto_pi stop[4075]: Java 1.8 or higher is required. Aborting launch.
Oct 29 08:38:44 homeauto_pi systemd[1]: openhab2.service: control process exited, code=exited status=1
Oct 29 08:38:44 homeauto_pi systemd[1]: Unit openhab2.service entered failed state.

I have java 8 installed
I have tried setting JAVA_HOME in the profile text file already.
Any Help would be appreciated.

What is the output of “java -version” on your raspi?

java version “1.7.0_101”
OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-2~deb8u1+rpi1)
OpenJDK Zero VM (build 24.95-b01, interpreted mode)

I also have jdk-8-oracle-arm32-vfp-hflt in /usr/lib/jvm if that helps?

Yes, you should definitely switch to Oracle Java.

If the “java -version” command returned with the “1.7.” Version of OpenJDK, you are using this version!
You need to switch to the already installed Oracle version!

"su update-alternatives –config java " migth help

Hello, thanks for your replies, I used su update-alternatives –config java and set the version 8. So openhab is working. Problem solved!

I am having a similar problem on Ubuntu 16.04, and not sure if something I did in upgrading to the latest snapshot or something else. But appears OpenHab is not running and starting as a service. This is what i am seeing in Ubuntu.

 openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Sat 2016-10-29 19:47:34 EDT; 2min 25s ago
     Docs: http://docs.openhab.org
           https://community.openhab.org
  Process: 9489 ExecStop=/usr/share/openhab2/runtime/karaf/bin/stop (code=exited, status=1/FAILURE)
  Process: 9354 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=255)
 Main PID: 9354 (code=exited, status=255)

Oct 29 19:47:34 UbuntuHA systemd[1]: openhab2.service: Control process exited, code=exited status=1
Oct 29 19:47:34 UbuntuHA systemd[1]: openhab2.service: Unit entered failed state.
Oct 29 19:47:34 UbuntuHA systemd[1]: openhab2.service: Failed with result 'exit-code'.
Oct 29 19:47:34 UbuntuHA systemd[1]: openhab2.service: Service hold-off time over, scheduling restart.
Oct 29 19:47:34 UbuntuHA systemd[1]: Stopped openHAB 2 - empowering the smart home.
Oct 29 19:47:34 UbuntuHA systemd[1]: openhab2.service: Start request repeated too quickly.
Oct 29 19:47:34 UbuntuHA systemd[1]: Failed to start openHAB 2 - empowering the smart home.

Since I had nothing really configured… I just did uninstall, apt purge and reinstall and seems that corrected things. But no idea why I would have received the above errors.