I’ve just got jython working on both Windows and Linux, and some bits are a little bit different to the Wiki. I’m using Java 8, Jython 2.7.0 and a recent snapshot of OH1.8.0 on Windows 7 and OpenSuse 13.2
I found that (at least on Windows):
- The Python scripts must be in the scripts directory
- The extension of the script file must be “'py”
And on Linux, symlinking to the Jython library as suggested in the wiki didn’t work for me, so I added the link into the classpath in the startup script
Windows
Here’s the complete start.bat:
@echo off
:: set path to eclipse folder. If local folder, use ‘.’; otherwise, use c:\path\to\eclipse
set ECLIPSEHOME=server
:: set ports for HTTP(S) server
set HTTP_PORT=8080
set HTTPS_PORT=8443set JYTHON_HOME=C:\jython2.7.0
:: get path to equinox jar inside ECLIPSEHOME folder
for /f “delims= tokens=1” %%c in (‘dir /B /S /OD %ECLIPSEHOME%\plugins\org.eclipse.equinox.launcher_*.jar’) do set EQUINOXJAR=%%c:: start Eclipse w/ java
echo Launching the openHAB runtime…
java -Dpython.home=%JYTHON_HOME% -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=%HTTP_PORT% -Djetty.port.ssl=%HTTPS_PORT% -Djetty.home=. -Dlogback.configurationFile=configurations/logback.xml -Dfelix.fileinstall.dir=addons -Dfelix.fileinstall.filter=.\.jar -Djava.library.path=lib -Dorg.osgi.framework.bundle.parent=ext -Djava.security.auth.login.config=./etc/login.conf -Dorg.quartz.properties=./etc/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Djava.awt.headless=true -Dfelix.fileinstall.active.level=4 -cp %JYTHON_HOME%\jython.jar;%EQUINOXJAR% org.eclipse.equinox.launcher.Main % -console
Linux
Here’s start.sh:
#!/bin/sh
cd
dirname $0
# set path to eclipse folder. If local folder, use '.'; otherwise, use /path/to/eclipse/
eclipsehome=“server”;
# set ports for HTTP(S) server - temporarily non-default
HTTP_PORT=8080
HTTPS_PORT=8443
JYTHON_HOME=“/opt/jython”;
# get path to equinox jar inside $eclipsehome folder
cp=$(find $eclipsehome -name “org.eclipse.equinox.launcher_*.jar” | sort | tail -1);
echo Launching the openHAB runtime…
java
-Dpython.home=“$JYTHON_HOME”
-Dosgi.clean=true
-Declipse.ignoreApp=true
-Dosgi.noShutdown=true
-Djetty.port=$HTTP_PORT
-Djetty.port.ssl=$HTTPS_PORT
-Djetty.home=.
-Dlogback.configurationFile=configurations/logback.xml
-Dfelix.fileinstall.dir=addons -Dfelix.fileinstall.filter=.\.jar
-Djava.library.path=lib
-Dorg.osgi.framework.bundle.parent=ext
-Djava.security.auth.login.config=./etc/login.conf
-Dorg.quartz.properties=./etc/quartz.properties
-Dequinox.ds.block_timeout=240000
-Dequinox.scr.waitTimeOnBlock=60000
-Dfelix.fileinstall.active.level=4
-Djava.awt.headless=true
-cp $JYTHON_HOME/jython.jar:$cp org.eclipse.equinox.launcher.Main $
-console
If you want to start the Linux script in background mode, basically add one line:
…
-cp $JYTHON_HOME/jython.jar:$cp org.eclipse.equinox.launcher.Main $*
-console
> run.log 2>&1 &