0

I've got a jar file which contains a very simple program of displaying "Hello" message in the console. I want to run this jar file as a windows service. This service gets started without any hiccup (I'm using Tanuki's Java Service Wrapper), however, it simply wouldn't start the service.

Below is the error I'm facing

wrapper | The Hello Sample Application service was launched, but failed to start. wrapper | Please check the log file more information: C:\wrapper-windows-x86-32 -3.5.14\logs\wrapper.log Press any key to continue . . .**

4

1 に答える 1

0

You need to modify your program so that it keeps running. If not the service wrapper will terminate and windows will see a service that is supposed to be running but doesn't.
Try something like:

import java.io.*;
public class Hello {
  public static void main(String[] argv) {
    try {
      while(true){
        System.out.println("Hello Service World.");

        // Sleep - Otherwise we would eat up all CPU
        Thread.sleep(1000);
      }
    } catch(InterruptedException e) {
      e.printStacktrace();
    }
  }
}

Or start another thread and perform your service's work. ;)

于 2012-07-01T14:48:44.973 に答える