0

I have created one .jar file and am able to execute the .jar from a .bat file. Please find my TestBatFile.bat.

@ECHO OFF
start java -jar C:\Users\Karthikeyan\Desktop\TestingJar.jar

Then i created windows service to execute this file using the below command.

C:\Windows\system32>sc create "testservice" start= demand displayname= "MyService" binpath= C:\Users\Karthikeyan\Desktop\TestBatFile.bat

Service has been created successfully. But while am starting the service am getting the below error.

Error 1053: The service did not respond to the start or control request in a timely fashion.

Please find my below java file which i made as .jar file.

public class TestJarClass {

    public static void main(String args[]) {
        System.out.println("Service Started....");
    }
}
Karthikeyan
  • 1,505
  • 2
  • 21
  • 61
  • add something like `time /t >> C:\temp\serv.log` to the head of your .BAT and then check if the time is being written to that log file – user85421 Jan 19 '19 at 08:03
  • @CarlosHeuberger - time is writting in the `serv.log` if i ran the `.bat` file manually. If i try to start as a service then, its not writting. – Karthikeyan Jan 19 '19 at 08:11
  • than this is not a java problem/question, more like how to create a windows service.... I believe that a BAT cannot be run as a service, somehow you must create a service *program* that has a defined interface (C, C++, C#). I believe that there are some *wrappers* that can be registered as service and which call java programs, must search the internet or https://stackoverflow.com/q/68113/85421 – user85421 Jan 19 '19 at 08:15

0 Answers0