Install and deploy free Tomcat to register as a windows system service

Source: Internet
Author: User

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 following code. Mark the important code in Red:
 
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:
 
: DoRemove and: doInstall are equivalent to two methods for this bat file. One is doRemove and the other is doInstall. It is easy to understand the name. doInstall indicates that the service is installed, and the other is delete the service.
 
3. Red code 3:
If % 1 = install goto doInstall
If % 1 = remove goto doRemove
If % 1 = uninstall goto doRemove
 
However, what I use in the cmd command line is:
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.