18

I want to install my tomcat v7.0.12 as a service on my Windows 2008 Server. On the tomcat page I found this tutorial. But there isn't a service.bat file in my installation dir.

In the service overview of WS2008 it isn't possible easily create a new service like new->service ...

Gary
  • 13,303
  • 18
  • 49
  • 71
mybecks
  • 2,443
  • 8
  • 31
  • 43
  • I don't understand. Nowhere do the instructions say to use "New -> Service..." They seem pretty clear to me. What went wrong when you tried to follow them? This part is important: "**NOTE:** On Windows Vista or any other operating system with User Account Control (UAC) you must either disable UAC or right-click on cmd.exe and select "Run as administrator" in order to run this script. If UAC is enabled neither being logged on with an Administrator account, nor using the /user switch is sufficient." Server 2008 counts as "Vista or later". – Cody Gray - on strike May 07 '11 at 09:08
  • 1
    In my /bin folder there isn't a bat file called "service.bat". So it isn't possible to follow the instructions. – mybecks May 08 '11 at 08:39
  • 2
    You're supposed to *download* service.bat with the Tomcat installation. It's not something that's already supposed to be on your computer. – Cody Gray - on strike May 08 '11 at 10:19
  • 2
    Oh, I overlooked that there is a package called 32-bit/64-bit Windows Service Installer on the tomcat download page! – mybecks May 08 '11 at 15:06

9 Answers9

21

To Start Tomcat7 Service :

  • Open cmd, go to bin directory within "Apache Tomcat 7" folder. You will see some this like C:\..\bin>

  • Enter above command to start the service: C:\..\bin>service.bat install. The service will get started now.

  • Enter above command to start tomcat7w monitory service. If you have issue with starting the tomcat7 service then remove the service with command : C:\..\bin>tomcat7 //DS//Tomcat7

  • Now the service will no longer exist. Try the install command again, now the service will get installed and started: C:\..\bin>tomcat7w \\MS\tomcat7w

  • You will see the tomcat 7 icon in the system tray. Now, the tomcat7 service and tomcat7w will start automatically when the windows get start.

jam
  • 3,640
  • 5
  • 34
  • 50
Sunil
  • 219
  • 2
  • 4
13

You can find the solution here!

Install the service named 'Tomcat7'

C:\>Tomcat\bin\service.bat install

There is a 2nd optional parameter that lets you specify the name of the service, as displayed in Windows services.

Install the service named 'MyTomcatService'

C:\>Tomcat\bin\service.bat install MyTomcatService
Federico Traiman
  • 1,191
  • 1
  • 13
  • 18
6

Looks like now they have the bat in the zip as well

note that you can use windows sc command to do more

e.g.

sc config tomcat7 start= auto

yes the space before auto is NEEDED

Kalpesh Soni
  • 6,879
  • 2
  • 56
  • 59
3

I just had the same issue and could only install tomcat7 as a serivce using the "32-bit/64-bit Windows Service Installer" version of tomcat:

http://tomcat.apache.org/download-70.cgi

Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81
  • this is actually the first answer that answers the question. "But there isn't a service.bat file in my installation dir." – ylka Apr 12 '18 at 15:15
2

I have spent a couple of hours looking for the magic configuration to get Tomcat 7 running as a service on Windows Server 2008... no luck.

I do have a solution though.

My install of Tomcat 7 works just fine if I just jump into a console window and run...

C:\apache-tomcat-7.0.26\bin\start.bat

At this point another console window pops up and tails the logs (tail meaning show the server logs as they happen).

SOLUTION

Run the start.bat file as a Scheduled Task.

  1. Start Menu > Accessories > System Tools > Task Scheduler

  2. In the Actions Window: Create Basic Task...

  3. Name the task something like "Start Tomcat 7" or something that makes sense a year from now.

  4. Click Next >

  5. Trigger should be set to "When the computer starts"

  6. Click Next >

  7. Action should be set to "Start a program"

  8. Click Next >

  9. Program/script: should be set to the location of the startup.bat file.

  10. Click Next >

  11. Click Finish

  12. IF YOUR SERVER IS NOT BEING USED: Reboot your server to test this functionality

HepCat_
  • 73
  • 2
  • 2
    Please... you can just go into %TOMCAT_DIR%/bin with your preferred command prompt and execute the following command: "service.bat install" – bugske Jul 26 '12 at 12:09
  • @bugske Agree this is fine but when you are working with remote server then depending upon system configutations (which you cannot change) this approach may not work and in those scenarios approach by "HepCat_" will be useful. – hagrawal7777 May 10 '17 at 13:34
1

There are a lot of answers here, but many overlook a few points. I ran into the same issue and it was likely due to a combination of being a complete neophyte when it comes to tomcat. Even more I am rather new to web servers in general. I consider myself somewhat proficient user of windows, but I guess not proficient enough. In particular I don't work with services too much.

I did not have a startup.bat or any bat files. I only downloaded the 32-bit/64-bit Windows Service Installer. The bin that is created for that download is small - only 4 files. My colleagues were surprised that I did not have a catalina.bat etc... and I was too. Only the below four files in the bin. And no %CATALINA_HOME% or %TOMCAT_HOME% etc...

bootstrap.jar
tomcat-juli.jar
Tomcat7.exe
Tomcat7w.exe

With this setup I had some frustrations as setting parameters is done via the gui widget - very helpful I might add.

So nearly all the answers I have perused were not immediately applicable as many said, "go to bin and issue the startup.bat file" I am a neophyte but not so much to not be able to look into the bin and start such a file it is existed!

For my simple purposes (again remember that I am a neophyte at tomcat and even web servers) all I wanted to do was to be able to startup and shutdown the tomcat server from a cmd prompt window. Nothing too heavy duty. I am embarrassed to say how simple it is. It is probably evident to anyone with a shred of experience with services and such.

To Start server: <Tomcat Root>/bin>Tomcat7.exe start
To Stop server: <Tomcat Root>/bin>Tomcat7.exe stop

Found here - http://crunchify.com/how-to-start-stop-apache-tomcat-server-via-command-line-setup-as-windows-service/

I did not realize there was a separate download the 64-bit Windows zip file that has a tomcat server and all the standard array of cmd line tomcat management tools. This zip file has all the common startup/shutdown scripts, batch files for windows, including catalina.bat/.sh etc... Then all the above answers make sense and are rather trivial.

Remember I am a neophyte when it comes to tomcat and web servers. It appears these two downloads are somewhat mutually exclusive in the sense that if I download and install the 32-bit/64-bit Windows Service Installer version and the 64-bit Windows zip file the startup.bat file in the 64-bit Windows zip file version will not run or interact with the 32-bit/64-bit Windows Service Installer tomcat instance. But I am not sure about this point.

Paul
  • 7,155
  • 8
  • 41
  • 40
1
  1. Edit service.bat – Swap two lines so that they appear in following order: if not “%JAVA_HOME%“ == ““ goto got JdkHome if not “%JRE_HOME%“ == ““ goto got JreHome
  2. Open cmd and run command service.bat install
  3. Open Services and find Apache Tomcat 7.0 Tomcat7. Right click and Properties. Change its startup type to Automatic (with delay).
  4. Reboot machine to verify if the service started automatically
Petr Turek
  • 11
  • 1
  • I forgot to add, that then you will see the service automatically and do not need to use any sc command or Task scheduler. – Petr Turek May 08 '18 at 14:13
  • The first step I do only because I could not perform step 2., due to JRE only I have installed and not JDK. So you may skip it if step 2. works for you fine. – Petr Turek May 08 '18 at 14:13
0

I had a similar problem, there isn't a service.bat in the zip version of tomcat that I downloaded ages ago.

I simply downloaded a new 64-bit Windows zip version of tomcat from http://tomcat.apache.org/download-70.cgi and replaced my existing tomcat\bin folder with the one I just downloaded (Remember to keep a backup first!).

Start command prompt > navigate to the tomcat\bin directory > issue the command:

service.bat install

Hope that helps!

Wei Rong
  • 11
  • 2
0

its done through service.bat file in apache tomcat7

visit this blog .. install tomcat7 on windows

Vishal Sharma
  • 2,773
  • 2
  • 24
  • 36
  • 2
    While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Jan 30 '12 at 12:47
  • newer default versions of Tomcat no longer have a service.bat. see the answer from Muhammad Gelbana – Chip McCormick Feb 03 '14 at 01:16