Set EXTRA_JAVA_OPTS for JSR223 in start.bat

Hello :slight_smile:
I’m trying to get Jython running on my OpenaHAB-Installation.
I installed OpenHAB on my Windows Laptop and now I’d like to set the EXTRA_JAVA_OPTS in my start.bat accordingly, but the Getting Started Section only explains how to set this variable in the start.sh:

export EXTRA_JAVA_OPTS="-Xbootclasspath/a:/opt/openhab2/conf/automation/jython/jython-standalone-2.7.0.jar -Dpython.home=/opt/openhab2/conf/automation/jython -Dpython.path=/opt/openhab2/conf/automation/lib/python"

How can I set this variable correctly in the start.bat File?

Good question… I haven’t tried. Based on this info, it looks to me (untested and a bit of a guess) that you would do something like this (but with the proper paths for Windows)…

SET EXTRA_JAVA_OPTS=-Xbootclasspath/a:/opt/openhab2/conf/automation/jython/jython-standalone-2.7.0.jar -Dpython.home=/opt/openhab2/conf/automation/jython -Dpython.path=/opt/openhab2/conf/automation/lib/python

If this doesn’t work, you’ll need to manually set it as an environment variable. Let me know what you end up with and I’ll update the doc!

More examples here and here.

@Dim knows his way around a linux system very well, if my memory’s correct, he’s also sharp on Windows as well. If you run into issues, maybe he can help with setting the proper path.

I think that the link that Scott provided is the best solution: JSR223 Jython Openhab Imports Erroring?

In Windows the scripts are called in the following order:
start.bat -> karaf.bat -> setenv.bat

The best place to add EXTRA_JAVA_OPTS is in the setenv.bat file (some exist already). I will test this and maybe write up a PR for

  1. https://github.com/openhab/openhab-docs/edit/master/configuration/jsr223-jython.md
  2. https://github.com/OH-Jython-Scripters/openhab2-jython/blob/master/docs/Getting-Started.md
1 Like

The ONLY place you could set the EXTRA_JAVA_OPTS was in setenv.bat, since that script was setting it but not appending any previously set value to the new one. The best place is now start.bat…

I’m in the process of updating the docs.