I am evaluating the YAJSW for the following use cases for windows.
- Run Java Application as service
- Run the service using java specified in JRE_HOME path variable(%JRE_HOME%\bin\java.exe).
The second use case is very important and it allows 2 flexibilities a). to install any newer version of JRE(when ever java support is discontinued/user wish to install new JRE) b). Application is not affected by the new JRE installed by user
wrapper.conf
wrapper.working.dir = ${wrapper_home}
wrapper.java.command = ${jre_home}/bin/java
wrapper.java.app.mainclass = com.myapp.launcher.Main
wrapper.java.classpath.1 = ${wrapper_home}/jars/simple.jar
wrapper.java.additional.1 = -Xms3m
#wrapper.java.additional.2 = -Xmx512m
wrapper.ntservice.name = YAJSWSimple
wrapper.ntservice.displayname = YAJSWSimple
wrapper.ntservice.description = YAJSW Simple Service
wrapper.ntservice.starttype = AUTO_START
wrapper.ntservice.interactive = false
wrapper.ntservice.java.command = ${jre_home}/bin/java
Above mentioned configuration satisfies the Use case 1. I am able start/stop from both "YAJSWSimple" service from windows services and command files from yajsw(bat/startService.bat and bat\startService.bat)
I am not able to achieve the second use case with the help of wrapper.java.command
and wrapper.ntservice.java.command
config properties.
I checked the Path to executable property of YAJSWSimple service on the windows services list and it shows the following.
C:\Program Files (x86)\Java\jre7\bin\java.exe
-classpath C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11\wrapper.jar
-Xrs -Dwrapper.service=true
-Dwrapper.working.dir=C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11
-Djava.net.preferIPv4Stack=true -Djre_home="C:\Program Files (x86)\Java\jre7"
-Dwrapper_home=C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11\bat\/..
-Dwrapper.java.command="C:\Program Files (x86)\Java\jre7/bin/java"
-Dwrapper.ntservice.java.command="C:\Program Files (x86)\Java\jre7/bin/java"
-Dwrapper.config=C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11\conf\wrapper.conf
-Dwrapper.additional.1x=-Xrs
-Djna_tmpdir=C:\Users\sathish\AppData\Local\Temp
org.rzo.yajsw.boot.WrapperServiceBooter
The service expands the path I have specified in wrapper.java.command
and wrapper.ntservice.java.command
config properties.
To complete the second use case I want the Path to executable property of YAJSWSimple service to be as follows
%JRE_HOME%/bin\java.exe
-classpath C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11\wrapper.jar
-Xrs -Dwrapper.service=true
-Dwrapper.working.dir=C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11 -Djava.net.preferIPv4Stack=true
-Dwrapper_home=C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11\bat\/.. -Dwrapper.java.command="%JRE_HOME%/bin/java"
-Dwrapper.ntservice.java.command="%JRE_HOME%/bin/java"
-Dwrapper.config=C:\Users\sathish\Softwares\yajsw\yajsw-stable-11.11\conf\wrapper.conf
-Dwrapper.additional.1x=-Xrs
-Djna_tmpdir=C:\Users\sathish\AppData\Local\Temp
org.rzo.yajsw.boot.WrapperServiceBooter
How this can be achieved in YAJSW so that the installed service is not affected by the JRE upgrade ?.
I am going to do the evaluate the same use cases for linux/unix machines as well. I hope the same solution will work for other platforms as well.