Documenting openHAB 2

Thank you @splatch for the reply. I need some help here because I am stuck (I am trying to create a doc section on windows service installation steps)

I think that the problem is that the Karaf service wrapper installation does not take this directory layout file into account.

For example, if I execute:

openhab> feature:install service-wrapper
openhab> wrapper:install --name "openHAB2" --display "openHAB2" --description "openHAB 2 Service"
Creating missing directory: C:\openHAB2\userdata\bin
Creating file: C:\openHAB2\userdata\bin\openHAB2-wrapper.exe
Creating file: C:\openHAB2\userdata\etc\openHAB2-wrapper.conf
Creating file: C:\openHAB2\userdata\bin\openHAB2-service.bat
Creating missing directory: C:\openHAB2\userdata\lib\wrapper
Creating file: C:\openHAB2\userdata\lib\wrapper\wrapper.dll
Creating file: C:\openHAB2\userdata\lib\wrapper\karaf-wrapper.jar
Creating file: C:\openHAB2\userdata\lib\wrapper\karaf-wrapper-main.jar

Setup complete.  You may wish to tweak the JVM properties in the wrapper configuration file:
        C:\openHAB2\userdata\etc\openHAB2-wrapper.conf
before installing and starting the service.


MS Windows system detected:
To install the service, run:
  C:> C:\openHAB2\userdata\bin\openHAB2-service.bat install

Once installed, to start the service run:
  C:> net start "openHAB2"

Once running, to stop the service run:
  C:> net stop "openHAB2"

Once stopped, to remove the installed the service run:
  C:> C:\openHAB2\userdata\bin\openHAB2-service.bat remove

openhab>

The C:\openHAB2\userdata\etc\openHAB2-wrapper.conf has the following lines:

#********************************************************************
# Wrapper Properties
#********************************************************************
set.default.JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
set.default.KARAF_HOME=C:\openHAB2\runtime
set.default.KARAF_BASE=C:\openHAB2\userdata
set.default.KARAF_DATA=C:\openHAB2\userdata
set.default.KARAF_ETC=C:\openHAB2\userdata\etc

# Java Application
wrapper.working.dir=%KARAF_BASE%
wrapper.java.command=%JAVA_HOME%/bin/java
wrapper.java.mainclass=org.apache.karaf.wrapper.internal.service.Main
wrapper.java.classpath.1=%KARAF_BASE%/lib/boot/*.jar
wrapper.java.classpath.2=%KARAF_BASE%/lib/wrapper/*.jar
wrapper.java.library.path.1=%KARAF_BASE%/lib/wrapper/

If I try to run C:> C:\openHAB2\userdata\bin\openHAB2-service.bat run, I get the following error:

jvm 1    | Error: Could not find or load main class org.apache.karaf.wrapper.internal.service.Main

The org.apache.karaf.main-4.0.8.jar is in C:\openHAB2\runtime\lib\boot

If I change wrapper.java.classpath.1=%KARAF_BASE%/lib/boot/*.jar to wrapper.java.classpath.1=%KARAF_HOME%/lib/boot/*.jar, the script runs:

c:\openHAB2\userdata\bin>openHAB2-service.bat run
wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
jvm 1    |
jvm 1    | Jan 25, 2017 7:40:24 AM org.apache.karaf.main.lock.SimpleFileLock lock
jvm 1    | INFO: Trying to lock C:\openHAB2\userdata\tmp\lock
jvm 1    | Jan 25, 2017 7:40:24 AM org.apache.karaf.main.lock.SimpleFileLock lock
jvm 1    | INFO: Lock acquired
jvm 1    | Jan 25, 2017 7:40:24 AM org.apache.karaf.main.Main$KarafLockCallback lockAquired
jvm 1    | INFO: Lock acquired. Setting startlevel to 100

but none of the environment variables of openHAB 2 are taken into account… so the application does not work

To fix this, I need to modify (significantly) the C:\openHAB2\userdata\etc\openHAB2-wrapper.conf file (as suggested here: Install openHAB 2 in Windows 10 as Windows Service - #8 by ScoobyDrew)

See also my comment on: Update windows.md by DimitrisSar · Pull Request #262 · openhab/openhab-docs · GitHub

Is there a better way to install the service wrapper on windows so it that doesn’t require all these fixes to the wrapper config?

Ps: Using OH 2.0.0 Stable Release Build