[Windows] Using EXTRA_JAVA_OPTS

Tags: #<Tag:0x00007f616fdfb3a8>

I found that EXTRA_JAVA_OPTS could only be set in /runtime/bin/setenv.bat. This didn’t sound right, since nothing should be modified in the runtime directory, so I created a tiny PR that will append the EXTRA_JAVA_OPTS set in a Windows environment variable or start.bat to what is being set in the setenv.bat. This has been merged and should show up in S1604.

In case you’d like to implement this now, rather than use a snapshot, 2.5M2, or wait for 2.5, find this in /runtime/bin/setenv.bat…

:: set jvm options
set EXTRA_JAVA_OPTS=-XX:+UseG1GC ^
  -Djava.awt.headless=true ^
  -Dfile.encoding=UTF-8

… and change it to…

:: set jvm options
set EXTRA_JAVA_OPTS=-XX:+UseG1GC ^
  -Djava.awt.headless=true ^
  -Dfile.encoding=UTF-8 ^
  %EXTRA_JAVA_OPTS%

After you have this, you can add the EXTRA_JAVA_OPTS to your start.bat like this…

REM Add to the top of the file
set EXTRA_JAVA_OPTS=-Xbootclasspath/a:C:\openhab2\conf\automation\jython\jython-standalone-2.7.0.jar -Dpython.home=C:\openhab2\conf\automation\jython -Dpython.path=C:\openhab2\conf\automation\lib\python

… or add it permanently as an environment variable.

5 Likes

I try to install this new rule engine but something is still missing or wrong.
My config:
Hardware: Intel NUC I5 (5300) 8Gb RAM
OS: win10 build 1903 64bit
Java Runtime Environment:
openjdk version “1.8.0_232”
OpenJDK Runtime Environment (Zulu 8.42.0.21-CA-win64) (build 1.8.0_232-b18)
OpenJDK 64-Bit Server VM (Zulu 8.42.0.21-CA-win64) (build 25.232-b18, mixed mode)
openHAB version: 2.5.M4
I also made these configurations:
https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html
[Windows] Using EXTRA_JAVA_OPTS
Now I have run out ideas where the problem can be.
I uploaded the startup logs, included openhab.log, rules.log (I created separate log file for rules), and .bat files where I had to add additional config for NGRE engine.
I would welcome any idea what should I check or change to start to use it.

ruleengine_debug.log (52.7 KB)

Everything looks good, but the logs don’t show Jython being loaded. Have you downloaded the Jython jar file to the specified directory?

Yes, 3 times min. I started with 2.7.1 but I have same suspicion that it is not loading for some reason.


That’s why I started to investigate java error logs and found out that wrapper was not working. I fixed it.
One additional thing is, that standalone Python and MQTT is also installed to that mini PC. Can Python installation cause this problem?

I have had all sorts of issues with Jython and anything newer than 2.4 Stable. If you go back to 2.4 Stable you will have to modify the setenv.bat and the start.bat files per the instructions here:

But, if you’d like to try something in your current 2.5 M4 setup, check out this post:

It moves the jython standalone file into the boot folder (follow the directions). It worked for me to enable jython, but I still have problems. Jython works, but nothing loads at startup. I have to “touch” (add a space somewhere and save) a file to get it to load. Any thoughts you might have would help.

Another thing you need to make sure of is that you have jython logging enabled in the org.ops4j.pax.logging.cfg file. I can’t remember where I found it, but this is what I use (append to the bottom of the file).

#ADDED following Upgrade to 2.5.0 M4
log4j2.logger.org_openhab_core_automation.level = WARN
log4j2.logger.org_openhab_core_automation.name = org.openhab.core.automation
log4j2.logger.jsr223.level = DEBUG
log4j2.logger.jsr223.name = jsr223
# Added to limit JSR223/jython log outputs (every time a rule is fired)
log4j2.logger.smarthomeRuleStatusInfoEvent.name = smarthome.event.RuleStatusInfoEvent
log4j2.logger.smarthomeRuleStatusInfoEvent.level = WARN

Maybe some of this will help!

Thanks! I think it would help ans save some time for me. This file is in userdata/bin/etc. I have already created the logger script into separate file and now I modify it a little bit based on that. In a meantime I have figured out that Phyton and Groovy scripting is not working. Java scripting works.
I have these error messages when I add Groovy or Phytom scripts:
“2019-10-29 06:13:55.167 [INFO ] [me.core.service.AbstractWatchService] - ScriptEngine for groovy not available”
2019-10-29 06:14:43.334 [INFO ] [me.core.service.AbstractWatchService] - ScriptEngine for py not available
So surely you have right JSR223 is not loading for some reason. I will go through the linked conversation and come back with my findings.