tags:

views:

483

answers:

7

I would like to run a Java application as a service. Unfortunately, I am limited in that I can't use something like the Java Service Wrapper (which does appear to be an excellent tool).

Is there any way of running an executable JAR, as a service, without relying on external applications? I currently have the service installed, but it fails to start. This is where I am getting stuck and I haven't been able to find anything on Google other than information about the JSW.

Thanks.

+2  A: 

I haven't tried it (yet), but Launch4j looks like it could suit your needs.

dustmachine
+1  A: 

A program that should run as windows service must provide certain functions that the windows service manager uses to communicate with that service.

As long as there is no JVM that implements this functions directly (and I know of none) you will need some kind of wrapper.

I have successfully used srvany for a java based windows service (Basically it allows to run any program as windows service and it works fine with java)

Wolfgang
+5  A: 

There's an LGPL clone of the Java Service Wrapper: http://yajsw.sourceforge.net

BTW, IANAL, but I suspect that JSW people are spreading FUD, and their software can be used to service-enable commercial applications under GPL license, just like one can gzip a commercial app for redistribution. I could be completely wrong about this, though :)

ykaganovich
Based on the wording on wrapper.tanukisoftware.com/doc/english/licenseCommunity.html it is very clear that the Community Edition cannot be used with a non-Open Source program due to it being under the GPL.
Thorbjørn Ravn Andersen
GPL does not preclude non-Open Source programs from being used "with" GPL programs (e.g. it's perfectly fine to run commercial applications on Linux OS). It only precludes creating a derivative work by linking against GPL code and releasing it under non-GPL license. In this case, It's not clear to me that a derivative work is being created.
ykaganovich
Meh, you might be right. They distribute their stuff not under GPL, but under some weird license that requires distributed product software to be distributed under GPL regardless of it being a derivative product. I wonder if this is legal... but I guess it's best to assume that it is.
ykaganovich
A: 

one more option winrun4j. the license is eclipse's CPL.

Peter Smith
+2  A: 

Another option, Apache Commons Daemon's procrun. (see http://blog.platinumsolutions.com/node/234)

cpierceworld
A: 

The most simple way I found was RunAsService.

A co-worker recommended a tool called SC, but I did not try it.

toba303
A: 

JSmooth can do it, and it is scriptable with ant.

Thorbjørn Ravn Andersen
It appears that the service wrapper start breaking under Windows 7 :(
Thorbjørn Ravn Andersen