Take the 2-minute tour ×

I have an executable JAR file. Is it possible to create a Windows service of that JAR? Actually, I just want to run that on startup, but I don't want to place that JAR file in my startup folder, neither in the registry.

share|improve this question
Not in the registry also? Then why would you want it as a Service? –  o.k.w Oct 24 '09 at 9:17
@o.k.w is right if you are creating windows service, It'll create entry in registry. –  Ravi Parekh Sep 10 at 11:28

6 Answers 6

up vote 6 down vote accepted

This article should tell you all you need to know: "Running Java Applications as a Windows Service"

You can also use "Java Service Wrapper" (there is a community edition called YAJSW)

share|improve this answer
yajsw.sourceforge.net –  Steve Sep 30 '13 at 4:50

The easiest solution I found for this so far is the Non-Sucking Service Manager

Usage would be

nssm install <servicename> "C:\Program Files\Java\jre7\java.exe" "-jar <path-to-jar-file>"
share|improve this answer
I did same and it installed successfully but as soon as I run it, it says unexpected status SERVICE-PAUSED in response to START control –  aneela Oct 23 at 5:22
@kopernik, Same thing happening for me too..any help please.. –  Shakthi Dec 18 at 14:36

I've been experimenting with Apache Commons Daemon. It's supports windows (Procrun) and unix (Jsvc). Advanced Installer has a Java Service tutorial with an example project to download. If you get their javaservice.jar running as a windows service you can test it by using "telnet 4444". I used their example because my focus was on getting a java windows service running, not writing java.

share|improve this answer
For a Windows service WinRun4j is also a good candidate. It can double as a Java Launcher, or Service Wrapper. –  mcdon Nov 7 at 14:57

Tanuki changed license of jsw some time ago, if I was to begin a project, I would use Yet Another Java Service Wrapper, http://yajsw.sourceforge.net/ that is more or less an open source implementation that mimics JWS, and then builds on it and improves it even further.

EDIT: I have been using YAJSW for several years on several platorms (Windows, several linuxes...) and it is great, development is ongoing.

share|improve this answer

We use the Tanuki Service Wrapper for that. It's very configurable.

share|improve this answer
site is down!! X( –  Rakesh Juyal Oct 24 '09 at 9:39

With procrun you need to copy prunsrv to the application directory (download), and create an install.bat like this:

set PR_PATH=%CD%
SET PR_JAR=MyService.jar
SET STOP_CLASS=java.lang.System
rem ; separated values
rem ; separated values
prunsrv.exe //IS//%PR_SERVICE_NAME% --Install="%PR_PATH%\prunsrv.exe" --Jvm=auto --Startup=auto --StartMode=jvm --StartClass=%START_CLASS% --StartMethod=%START_METHOD% --StopMode=jvm --StopClass=%STOP_CLASS% --StopMethod=%STOP_METHOD% ++StopParams=%STOP_PARAMS% --Classpath="%PR_PATH%\%PR_JAR%" --DisplayName="%PR_SERVICE_NAME%" ++JvmOptions=%JVM_OPTIONS%

I presume to

  • run this from the same directory where the jar and prunsrv.exe is
  • the jar has its working MANIFEST.MF
  • and you have shutdown hooks registered into JVM (for example with context.registerShutdownHook() in Spring)...
  • not using relative paths for files outside the jar (for example log4j should be used with log4j.appender.X.File=${app.home}/logs/my.log or something alike)

Check the procrun manual and this tutorial for more information.

share|improve this answer
is there any example that you can share? –  Ravi Kumar Gupta Jun 12 '13 at 11:29
yes: see the one above :-) what else do you need? –  BTakacs Jun 17 '13 at 9:02
Thanks BTakacs, I already checked your tutorial and it worked fine. But unfortunately that did not solve what I wanted to do.. I am trying to achieve that now from C#. –  Ravi Kumar Gupta Jun 17 '13 at 10:13
well, in that case you should check that answer: stackoverflow.com/a/15115104/566006 –  BTakacs Jun 17 '13 at 14:24

Your Answer


