Create Windows Service Application with JAVA (procrun)

Alhamdulillah, after using one full days to create windows service in java, I already made it based on tutorial at here. So, I just want to create another my own tutorial, so I hope it can help you to create windows service in java with procrun wrapper.

I used :

  • jdk-7u4-windows-x64 (windows 7 64)
  • IDE netbeans 7
  • Log4j 1.2.17
  • Procrun

To create windows service in java wit procrun :

  • my windows service source code
import org.apache.log4j.Logger;
* @author arif
public class Driver {
private static Logger log = Logger.getLogger("windowsservicelog");
private static boolean stop = false;
public static void start(String[] args) {
while (!stop) {
try {
} catch (InterruptedException e) {
public static void stop(String[] args) {"stop");
stop = true;
static void main(String args[]) {
String mode = args[0];
switch (mode) {
case "start":
case "stop":
  • my log4j configuration
# Root logger option
log4j.rootLogger=debug, file, stdout
# Direct log messages to a log file
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Direct log messages to stdout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
  • simple template procrun script
procrun.exe //IS//<your service name> --Install="<your procrun path>procrun.exe" --Jvm=auto --Startup=auto
--StartMode jvm --StartClass <your start class> --StartParams start
--StopMode jvm --StopClass <your stop class> --StopParams stop
--Classpath="<your service jar path><your service jar>.jar" --DisplayName="<your display service name>"
  • my procrun script
procrun.exe //IS//SampleService --Install="D:sample_windows_serviceprocrun.exe" --Jvm=auto --Startup=auto
--StartMode jvm --StartClass --StartParams start
--StopMode jvm --StopClass --StopParams stop
--Classpath="D:sample_windows_servicejava_windows_service.jar" --DisplayName="Sample Service JAVA"

complete tutorial, project and my service folder

11 thoughts on “Create Windows Service Application with JAVA (procrun)

  1. This is the right website for anyone who hopes to find out about this topic.
    You know so much its almost tough to argue with you (not that I really would
    want toHaHa). You certainly put a fresh spin on a topic that’s been discussed for years.
    Excellent stuff, just great!

  2. Just wish to say your article is as astonishing.

    The clearness in your post is simply nice and i can assume you are an expert on this
    subject. Well with your permission let me to grab your RSS feed to
    keep up to date with forthcoming post. Thanks a
    million and please continue the gratifying work.

  3. Pingback: Google

Leave a Reply

Your email address will not be published. Required fields are marked *

Afiseaza emoticoanele Locco.Ro