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.

Context
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

JAVA_HOME="/usr/lib/jvm/zulu11-ca-amd64/"

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

2 Likes

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