2

I am evaluating the YAJSW for the following use cases for windows.

  1. Run Java Application as service
  2. 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
  1. How this can be achieved in YAJSW so that the installed service is not affected by the JRE upgrade ?.

  2. 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.

1 Answers1

0

I create a windows service which satisfied both cases with the following in wrapper.conf:

wrapper.java.command = java

This effectively using the same version of java that is specified when typing java -version. After every JRE update, java -version reveals that the latest version is being used, thus the latest version will be used by YAJSW.

I have noticed on my setup, (Windows 7 x32, YAJSW 11.11) that after installing/updating the JRE, neither JRE_HOME or JAVA_HOME is set, and echo %PATH% reveals that java is not set in path like it should be, yet typing java -version always is updated after install/update. I then found that java.exe, javaw.exe and javaws.exe is present in C:\Windows\System32\, and is updated after every update. Thus, simply using java in wrapper.conf will point to the last installed JRE.

Ian2thedv
  • 2,691
  • 2
  • 26
  • 47