Take the 2-minute tour ×

Have you had experience with running a jar file using a command line, wrapped in a Windows service?

I'm trying to find a way to run a jar file without being logged into the machine, and since it allows command shell, I was wondering if it's a good idea.


Original Post:

I'm trying to run Associated Press's Web Feeds Manager, which is basically a jar file that can be run when logged in by double clicking it.

I'd like to run the same file but without being logged in to the machine. In their manual (http://wfm.ap.org/admin/content/help/Running_Agent_on_a_Remote_Server.htm) they write how to do that, using a commandline parameter.

Basically I'd like the jar to run as a Windows service, regardless of who's logged in, but Googling it showed it was problematic.

Have you had experience with remotely running jar files? What are the pitfalls?


share|improve this question
After seeing the responses, I'm trying a different approach. –  Nir Dec 26 '12 at 11:31
Even in that case, please mark the answer which seems useful for your question. –  Swapnil Dec 27 '12 at 10:57

5 Answers 5

up vote 1 down vote accepted

On a google search, I came across this article -

Running Jar Applications as a Windows Service

It mentions about open source Java Service Wrapper project from Tanukisoftware.org for accomplishing this task.

Note: I've not used this personally.

share|improve this answer

If you are not interested in having the service started/stopped at boot/shutdown, but you just want the program to be started manually and keep running after logout, here is what you do:

$ nohup java -jar foobar.jar > foobar.log 2>&1 &

which means: start my foobar.jar (java -jar) and keep it running after I logout (nohup) redirect stdout to foobar.log (>) and also the stderr (2>&1), and make it running in background (& at the end).

Instead, if you are interested in installing a "service" in your linux box, there are many options, depending on what distribution you are using. The most common are upstart (for ubuntu) and System V init scripts (Redhat or others). Also cron can be used to start/stop services at startup/shutdown. You can find an example of installing a java app (hudson) on an init system here, or doing the same thing with upstart. Or, as I said, cron could be an option.

On Windows, there is Java Service Wrapper. And not much more.

share|improve this answer

For windows Java Service Wrapper is a better choice

share|improve this answer

My favourite is the upstart on linux, but it is Ubuntu only.

On Windows I see many alternatives according to this forum.

share|improve this answer

Tool Exe4j

You can use Exe4j.exe, that tool generate service.exe file from .jar file

You can download Exe4j from here: Download exe4j

share|improve this answer

Your Answer


