Can I start OH 3.1 in a different Java environment?

Hi Community. Thank you for the work you are doing with OH 3, it’s a hobby for me at the moment while I figure out what I can do with it. Plenty of inspired posts to keep me going but for now I have a Java questions please.

TIA for reading and devoting mind-time to this.

I’m using a relatively recent desktop computer, plenty of RAM and HDD space, running Ubuntu 20.04 LTS headless server with:

  • OpenHab 3.1
  • SubSonic
  • Nextcloud
  • Homebridge
  • Wordpress
  • Apache2
  • MariaDB

I have some mid-level skills in this space, so am able to understand complex concepts but my search skills are frustrating me, so I thought I would ask to see if anyone else has the experience to help me a little faster than me trying to help myself.

The Ask
May I ask if it’s possible to start up OH 3.1 in a separate Java environment. I have Zulu 8, 11 and openJDK 8 and 11 on the dekstop. Default is current Zulu 8 because Subsonic is used heavily by the family and is incompatible with 11. Funny thing, OH3.1 is incompatible with 8.

So, easiest thing I could think of was use 8 and see if I can run OH3.1 by specifying a different Java environment specifically for it.

I came across this post: How to point OH2 to a different java version and while that is specific to rPI installs, does anyone have experience with OH3 in Ubuntu to start in a different Java environment to the default as chosen through ’ sudo update-alternatives --config java ’ (which will break my SubSonic install).

Yes, yes I know the obvious answer may be “jeez just use a few Raspbery Pi’s and all the problems will go away” but I really just want one Platform

I have sort of the same issue, running a unifi controller (which requires java 8) on the same computer as openhab. Adding


To /etc/default/openhab makes OH use java 11 instead. (Of course you might need to adapt the path to your setup).


Mate, Anders, if you’re ever traveling near Canberra let me know and I’ll shout you a beer (or coffee).

Worked like a charm, thank you.

Mine was JAVA_HOME="/usr/lib/jvm/zulu-11-amd64/"

Not really Java 8 & 11 are both LTS versions but Java 8 is nearing its end of support for patches, etc. OH3 will NOT run in Java 8. Perhaps you could use a container system such as Docker to run OH in a container. I have successfully run OH 2 & 3 in containers on the same system.

That’s fair enough - Docker is a little foreign to me so far. I’m used to being able to have full control over (for example) the ports I run things on. This desktop being a ‘jack of all trades’ I’m trying to keep it under as much control as I can.

However, not to fear - the solution for me was to edit the configuration file for OH and specify the java home directory - works like a charm now :slight_smile:

1 Like

Is there any identical way for a windows enviroment? any hints for me?

Windows as well uses JAVA_HOME to identify the java installation to be used.

Yes, i know.
But because of other application JAVA_HOME is alreday set to another java installtion.

Also tried now to work with the wrapper and absolut path to zulu 11, but also got errors about the Equinox container

# openHAB-wrapper.conf for Windows Service Installation

# openHAB installation dir (Adapt this first setting to your system)

# Wrapper Properties

# Java Application
wrapper.working.dir=%KARAF_BASE%\Program Files\Zulu\zulu-11\bin\java\lib\boot\*.jar\lib\wrapper\*.jar\lib\jdk9plus\*.jar\lib\endorsed\*.jar\lib\wrapper\


# Wrapper Logging Properties

# Wrapper Windows Properties
wrapper.ntservice.description=openHAB Service

All other error messages that i found in relation to Equinox container are related to using the wrong Java version.
According to my limited understanding it is essential to have JAVA_HOME set to the correct value.
As you mentioned you need to use JAVA_HOME set to an other version. I would assume that this is the problem.
Can’t you set JAVA_HOME for just that one user in the users environment settings overruling the system wide set JAVA_HOME envorinment variable ? For a test you may set that environment variable just before starting up OH from within a cmd box.

I found my problem…
The given absoult path to Zulu11 was not right…

So finally it works without handling JAVA_HOME for OH3 by starting OH3 as a service with the absolut path to ZULU11 inside the wrapper config.