title: Running Java jars as windows service
body: <p>I have an executable jar and I was trying to create a Windows Service using sc.exe. I used the below code for creating service:</p>
  
  <pre><code>sc create "TestService" binPath= "C:\Program Files\Java\jdk1.6.0_03\jre\bin\java.exe -jar C:\abc\MainClass.jar"
  </code></pre>
  
  <p>The service got created but when I was trying to start the service I got the below error: </p>
  
  <pre><code>Error 1053: The service did not respond to the start or control request in a timely fashion.
  </code></pre>
  
  <p>Later I tried to use Java Service Wrapper (Community Edition), the service starts for some time but is getting stopped everytime. The wrapper log tells something like:</p>
  
  <pre><code>Advice:
  The Wrapper consists of a native component as well as a set of classes
  which run within the JVM that it launches.  The Java component of the
  Wrapper must be initialized promptly after the JVM is launched or the
  Wrapper will timeout, as just happened.  Most likely the main class
  specified in the Wrapper configuration file is not correctly initializing
  the Wrapper classes:
  com.MainClass
  While it is possible to do so manually, the Wrapper ships with helper
  classes to make this initialization processes automatic.
  Please review the integration section of the Wrapper's documentation
  for the various methods which can be employed to launch an application
  within the Wrapper
  </code></pre>
  
  <p>Could anyone please tell me how can I run jar as a Windows Service without using external software as I can't use any third party app on Client's prod env.</p>
  
  <p>If not what other configs I need to do in Java Service Wrapper to make the service start.</p>
  
  <p>I tried to find some info related to this on stackoverflow but I did not get anything thing. If any one has anything on stackoverflow please feel free to put this in comment.</p>