Install-free tomcat to register as a Windows Service

Source: Internet
Author: User
Source http://www.iteye.com/topic/426413

Download the free installation version of Tomcat 5.5.20 from the official website of Apache Tomcat. register it as a system service and start it on your own.
1. first, check whether the system has installed a previous version of Tomcat. If yes, delete it. To delete it, go to the control panel of Windows ---> Computer Management ---> Service
Check whether there are any services related to Apache or tomcat in the service list,
If yes, right-click the service above ---> Properties and write down the service name. For example, tomcat6

In this case, go to the Windows Command Line and Start Menu ---> RUN ---> cmd

Enter
SC Delete tomcat6
You can delete it now. Tomcat 6 of the preceding command line is the attribute name in the system service.

2. register a new service
In the command line, go to the bin directory under the downloaded installation-free Tomcat directory.
Run in this bin directory
Service. Bat install
In this case, the installation-free Tomcat can be registered as a system service,
Go to the control panel of Windows> Computer Management> service, and you will be able to see the newly added service in the service list.

In fact, the principle is very simple as described above. Let's talk about this basic principle below,
The tomcat/bin directory contains a service. BAT file. The BAT file is executed,
Open the service. BAT file and you will find the followingCodeImportant codeRedMARK:

Set executable = % catalina_home % \ bin \ tomcat5.exe

Rem set default service name
Set SERVICE_NAME = tomcat5
Set pr_displayname = Apache Tomcat

If "% 1" = "" Goto displayusage
If "% 2" = "" Goto setservicename
Set SERVICE_NAME = % 2
Set pr_displayname = Apache Tomcat % 2
: Setservicename
If % 1 = install goto doinstall
If % 1 = remove goto doremove
If % 1 = uninstall goto doremove
Echo unknown parameter "% 1"
: Displayusage
Echo.
Echo usage: Service. Bat install/remove [SERVICE_NAME]
Goto end

: Doremove
Rem remove the service
"% Executable %" // DS // % SERVICE_NAME %
Echo the Service '% SERVICE_NAME %' has been removed
Goto end

: Doinstall
Rem install the service
Echo installing the Service '% SERVICE_NAME % '...
Echo using catalina_home: % catalina_home %
Echo using catalina_base: % catalina_base %
Echo using java_home: % java_home %

1. Red code 1:
Set SERVICE_NAME = tomcat5
Set pr_displayname = Apache Tomcat
If you set Tomcat as a service, you will see in the System Service that the service name is set here.
If you change the service name, you can replace the SERVICE_NAME and pr_displayname values above.

2. Red Code 2:

: DoremoveAnd: DoinstallThis code is equivalent to the BAT file which has two methods: doremove and doinstall. The name is understandable. doinstall indicates that the service is installed, and doremove indicates that the service is deleted.

3. Red code 3:
If % 1 = install goto doinstall
If % 1 = remove goto doremove
If % 1 = uninstall goto doremove

However, in the CMD command line, the following commands are used:
Service. Bat install
How is it mapped?
We can see through the code below that % 1 indicates that we are in the service. the first parameter entered by Bat install is install, that is, % 1 = install. If % 1 = install goto doinstall
Then execute the doinstall method to install the service to the system,
The simplest way to delete a service is:
Service. Bat remove
Or
Service. Bat uninstall

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.