Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Windows 10 + Tomcat 8 + jdk 1.8 + Service Registration + bat automatic installation configuration

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Windows 10 + Tomcat 8 + jdk 1.8 + Service Registration + modify Service Startup Type + bat automatic installation configuration method

1. Download the jdk1.8 and Tomcat 8 installation packages from the official website

Jdk-8u172-windows-x64.exe (website: http://www.oracle.com/technetwork/java/javase/downloads/index.html)

Apache-tomcat-8.5.32-windows-x64.zip (website: http://tomcat.apache.org/)

2. Make jdk installation-free package

Double-click jdk-8u172-windows-x64.exe to install the software

Instead of clicking change in this step, click next.

After the installation is complete, copy the C:\ Java\ directory completely, and you can get the JDK installation-free package.

3. The installation package of Tomcat 8 can be used after decompression.

4. Organize the installation package and write the bat file

The installation package directory architecture is as follows:

C:\ tomcat

├─ tomcat

│ ├─ apache-tomcat-8.5.32 (Tomcat 8.5.32 extracted directory)

│ │ ├─ bin (copy the four files catalina.bat, service.bat, startup.bat, shutdown.bat to the tomcat_bin folder, and delete the source files after the copy)

│ │ ├─ conf

│ │ ├─ java-1.8 (copied JDK 1.8 installation package)

│ │ ├─ lib

│ │ ├─ logs

│ │ ├─ temp

│ │ ├─ webapps

│ │ └─ work

├─ tomcat_bin (stores home.bak, catalina.bak.bat, service.bak.bat, startup.bak.bat, shutdown.bak.bat files)

├─ install.bat (automatic installation script)

└─ confing.txt (automatically generated after the execution of the automatic installation script, storing the installation path and other information)

5. Document description

The files under the tomcat_bin folder are used in install.bat, where the content of the home.bak file is empty. The four files catalina.bak.bat, service.bak.bat, startup.bak.bat and shutdown.bak.bat are the backups after the first line (@ echo off) of the four files copied from the bin file are deleted, and the source files are deleted.

6. Contents of install.bat file

Echo off

Rem Get the current path

Set paid path% CD%

Rem Get the installation path

Set/p "I_PATH=Please enter the installation path:"

Rem Check whether the installation path exists.

Rem If the path already exists, exit.

Rem if no exists,creation installation path.

If exist% iPATH% goto I_PATH_EXIT

If not exist% iPATH% goto I_PATH_ONT_EXIT

: I_PATH_EXIT

Echo% iTunPATH% Already exist, please replace

Set/p "I_PATH=Please enter the installation path:"

If exist% iPATH% goto I_PATH_EXIT

If not exist% iPATH% goto I_PATH_ONT_EXIT

: I_PATH_ONT_EXIT

Mkdir% Illumination path%

Mkdir% Illumination path%\ tomcat

Rem echo Copy the file to the installation directory

Rem xcopy directory, copy file

Xcopy% Cellular path%\ tomcat% Illustrated path%\ tomcat / s

Echo @ echo off >% Cellular path%\ tomcat_bin\ home.bat

Echo set CATALINA_HOME=%I_PATH%\ tomcat\ apache-tomcat-8.5.32 > >% accounts path%\ tomcat_bin\ home.bat

Echo set JAVA_HOME=%I_PATH%\ tomcat\ apache-tomcat-8.5.32\ java-1.8 > >% accounts path%\ tomcat_bin\ home.bat

Type% CentralPat%\ tomcat_bin\ home.bat% ClearPat%\ tomcat_bin\ catalina.bak.bat > >% CentralPATH%\ tomcat_bin\ catalina.bat

Type% CentralPat%\ tomcat_bin\ home.bat% ClearPat%\ tomcat_bin\ service.bak.bat > >% CentralPATH%\ tomcat_bin\ service.bat

Type% CentralPat%\ tomcat_bin\ home.bat% ClearPat%\ tomcat_bin\ startup.bak.bat > >% CentralPATH%\ tomcat_bin\ startup.bat

Type% CentralPat%\ tomcat_bin\ home.bat% ClearPat%\ tomcat_bin\ shutdown.bak.bat > >% CentralPATH%\ tomcat_bin\ shutdown.bat

Move% apache-tomcat-8.5.32 path%\ tomcat_bin\ catalina.bat% Illustrated path%\ tomcat\ apache-tomcat-8.5.32\ bin\

Move% apache-tomcat-8.5.32 path%\ tomcat_bin\ service.bat% Illustrated path%\ tomcat\ apache-tomcat-8.5.32\ bin\

Move% apache-tomcat-8.5.32 path%\ tomcat_bin\ startup.bat% Illustrated path%\ tomcat\ apache-tomcat-8.5.32\ bin\

Move% apache-tomcat-8.5.32 path%\ tomcat_bin\ shutdown.bat% Illustrated path%\ tomcat\ apache-tomcat-8.5.32\ bin\

@ timeout 5

Rem Register as a service

Call% apache-tomcat-8.5.32 path%\ tomcat\ apache-tomcat-8.5.32\ bin\ service.bat install

@ timeout 3

Sc config Tomcat8 start= auto

@ timeout 3

Net start Tomcat8

Rem Generate configuration file

Echo system installation path:% iTunes path%\ tomcat >% accounts path%\ confing.txt

Echo system startup command: net start Tomcat8 > >% Cellular path%\ confing.txt

Echo system shutdown command: net stop Tomcat8 > >% accounts path%\ confing.txt

Echo can start or shut down the system through the service (boot is configured) > >% Cellular path%\ confing.txt

Echo system service installation command:% Iaccounts path%\ tomcat\ apache-tomcat-8.5.32\ bin\ service.bat install > >% accounts path%\ confing.txt

Echo system service uninstall command:% Iaccounts path%\ tomcat\ apache-tomcat-8.5.32\ bin\ service.bat remove > >% accounts path%\ confing.txt

Pause

7. Double-click install.bat, enter the path you want to install, and install it automatically.

C:\ app is the installation path

At this point, the automatic installation is successful and has been started

8. Native access test

9. View the contents of confing.txt

System installation path: C:\ app\ tomcat

System boot command: net start Tomcat8

System shutdown command: net stop Tomcat8

The system can be started or shut down through the service (boot self-startup has been configured)

System service installation command: C:\ app\ tomcat\ apache-tomcat-8.5.32\ bin\ service.bat install

System service uninstall command: C:\ app\ tomcat\ apache-tomcat-8.5.32\ bin\ service.bat remove

10. Reference documentation

Syntax and skills of https://www.jb51.net/article/5828.htm BAT files (compilation and implementation of bat files

Use)

Https://blog.csdn.net/ttx_laughing/article/details/52919456 registers tomcat as a service and modifies the startup type

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report