Reputation: 12484
I downloaded Apache Daemon , but I'm having some problems with running it.
In the command line I'm trying to extract the JAR
files (file dir. shown below) :
I am doing so , by using this command (in CMD) :
jar -xf commons-daemon-1.0.15.jar
But this doesn't do anything. I was looking for a way to start-up the Daemon tools so that windows can start running a Java service.
any tips helpful , thanks
Upvotes: 0
Views: 6738
Reputation: 2431
According to the Apache site http://commons.apache.org/proper/commons-daemon/procrun.html,
"Procrun is a set of applications that allow Windows users to wrap (mostly) Java applications (e.g. Tomcat) as a Windows service.The service can be set to automatically start when the machine boots and will continue to run with no user logged onto the machine."
Procrun consists of two applications, Prunmgr, and Prunsrv. Prunmgr is a GUI application for monitoring and configuring procrun services. Prunsrv is a service application for running applications as services. It can convert any application (not just Java applications) to run as a service.
Download location for Prunmgr and Prunsrv here: http://www.apache.org/dist/commons/daemon/binaries/windows/
Note: You may also download these two executable from the Tomcat website. http://tomcat.apache.org/download-90.cgi However, you will not find the files that you're expecting to see. Tomcat uses the same files, however, they simply renamed them to something else. If you want to use Tomcat version 9, Prunsrv is Tomcat9.exe and Prunmgr is Tomcat9w.exe
For my basic example, I created a sample project in Eclipse and used the sample code from this source: http://web.archive.org/web/20090228071059/http://blog.platinumsolutions.com/node/234
Note: I did have to install JDK 7 since Eclipse Mars required JDK 7.
I then needed to convert my Java file into a class file using the javac executable. Once I got the class file, I created a directory structure that looks like the following image. Note, I renamed Prunmgr to myServicew.exe and Prunsrv to myService.exe.
E:\MyService
\bin
\myService.exe
\myServicew.exe
\classes
\MyService.CoolService.MyService.class
\logs
Using command line or Windows Powershell, navigate to your bin directory and use the following command to install the Windows service:
myService.exe //IS//MyService --Install=E:\MyService\bin\myService.exe --Description="My Java Service" --Jvm=C:\glassfish4\jdk7\jre\bin\server\jvm.dll --Classpath=E:MyServiceclasses --StartMode=jvm --StartClass=MyService.CoolService.MyService --StartMethod=windowsService --StartParams=start --StopMode=jvm --StopClass=MyService.CoolService.MyService --StopMethod=windowsService --StopParams=stop --LogPath=E:\MyService\logs --StdOutput=auto --StdError=auto
You should now see your service in Windows Services.
Upvotes: 6