title: How do I run a Java .jar file as a Windows service on Windows Server 2008?
body: <p>How do I run a Java .jar file as a Windows service on a Windows 2008 server? I have a jar file called SomeJavaFile.jar located under the <code>C:\SomeDirectory</code> directory on a Windows Server 2008 box. I usually just run this jar manually in the command line with: <code>java –cp SomeJavaFile.jar com.ctg.SomeJavaFile</code> and I let it run 24/7.</p>
  
  <p>The problem with our Windows Server is if it restarts I need to run it as a service so it will automatically start as a service upon startup, because our processing for Vistakon runs 24/7. I have Googled around and tried to use a service wrapper and the sc.exe command to create the service.</p>
  
  <p>I put the wrapper service.exe in the <code>C:\SomeDirectory\</code>. I use the following command to create it: <code>sc.exe SomeJavaService binPath= “C:\SomeDirectory\service.exe \”java –jar C:\SomeDirectory\SomeJavaFile.jar\”” type= own start= auto error= ignore</code>. This creates the SomeJavaService service correctly but when I try to start it I get an error that says the service on Local Computer started then stopped.</p>
  
  <p>Some services stop automatically if they are not in use by other services or programs. Do I need to alter my sc.exe command to have the exact previous working command line maybe, by adding in the com.ctg.SomeJavaFile? So should I change This jar should just run in the background and constantly poll/ping the C:/poll directory then if there is data present it processes the data and sends an export file to another directory.</p>
  
  <p>I have used this same .jar file for years successfully and it hasn't changed, but I cannot get it to run as a Windows service. This is the site I use to get the service wrapper <a href="http://code.google.com/p/simple-service-wrapper/" rel="nofollow noreferrer">http://code.google.com/p/simple-service-wrapper/</a>. Any help would be greatly appreciated!</p>