[SOLVED] ERROR:Could not create the Java Virtual Machine WHEN RUN OSGi

  • Platform information:
    • Hardware: 16G RAM
    • OS: macOS
    • Java Runtime Environment: zulu8
    • openHAB version:2.5
  • Issue of the topic:
    I try to develop my new binding in eclipse, everything goes fine before entering the app.bndrun in the demo.app, when clicking Run OSGi, it just get error,can someone please help me? thanks a lot!

the error goes like this:

Unrecognized option: --add-opens

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

You need to use the 2.5.x branch of openhab-distro. Use git checkout to get that branch. You are now on the master branch of the openhab-distro that is intended for java 11 support.

Thanks for your reply! I’m a green hand to the openhab2, so I got confused, do you mean after clone these addons from the git, should I use git checkout to get another branch? Because all of the binding that I imported into the eclipse are from the folder I downloaded.

If you install eclipse with the eclipse installer and selected openHAB development it will also create a directory git/openhab-distro. This is where the demo app is located. You need to checkout the branch 2.5.x in openhab-distro. There were some recent changes with the installer, depending on when you installed eclipse via the eclipse installer you could(can) select a specific version you want to use, but if you selected master or have an older version which only had master you need to checkout 2.5.x.

This is independent from the openhab-addons repository. But if you did clone that repository also make sure you start by checking out the 2.5.x branch.

I’ve just change the branch in openhab-distro, hope it will work! Again,thanks for your reply!