How to install a Java application as a service

2019-08-05 01:58发布

问题:

I have a Java Application written that forwards selected files to an ssh server. I want this application to be automatically run every time windows starts.

I am aware that this question has been asked multiple times, and I have followed those leads. I have tried Java Service Wrapper (which is no longer accessible because of a dns problem), Apache Daemon, and JSL. Though I have at times been able to get the application installed as a service, I have never been able to get it to run properly on boot, or even start it manually from the command line.

My question is whether anyone is aware of a full first step through final step tutorial of how to make this work. I have come across a few things, but they all either assume that you have implemented something that they do not explain how to implement, or rely on applications that I do not have installed.

Thanks

回答1:

I use Java Service Wrapper to install as windows or linux service: http://wrapper.tanukisoftware.com/doc/english/download.jsp

~> create one runnable JAR to your app.

~> Download the proper service wrapper (they are diffrent to windows and linux)

~> Configure the service in wrapper.conf

Important: set wrapper.java.classpath correct (your jar must be here too) Set wrapper.java.mainclass with org.tanukisoftware.wrapper.WrapperSimpleApp
Set wrapper.app.parameter.1 with the name of your main class, for example:

wrapper.app.parameter.1=Main

~> Test the service as console (windows bat)