Search code examples
war

How to run war file as a service on Windows 7?


How can I run the war file as a service on Windows? Actually, I want to run my war file when I start my machine. How to do it?


Solution

  • If your application is a spring boot application then you just refer this link:-

    https://stackoverflow.com/a/58637513/8199738

    If your application is not made up of spring boot then just follow the below steps:-

    1. Download a tomcat 7 or above version for windows from the official site tomcat.org
    2. Copy your war file and paste it to the tomcat/webapp folder.
    3. Open Command prompt and navigate to the tomcat's /bin folder
    4. Execute the service.bat as follows to create a service.

      service.bat install service_name

    5. Open Services manager and you could see a service running with the service_name as you created.

    6. when you select the service, you could see the options like start/stop/restart on the left side. enter image description here

    7. You can also make the service to run automatically whenever the system gets restarted. Select service -> Right Click -> Properties -> Startup Type -> Select Automatic. enter image description here

    Hope! it helps! Thanks!