Detailed explanation of the solution to Tomcat's crash when double-clicking startup.bat

Detailed explanation of the solution to Tomcat's crash when double-clicking startup.bat

As a programmer who has just learned Tomcat, this is a common mistake.

1. Environment variable problem

1.1 First, you need to confirm whether the Java environment is configured correctly and whether the JDK is installed correctly

win+R to open cmd, enter java or javac
The following figure shows that the JDK configuration is correct:

insert image description here

If not, refer to JDK installation and configuration. If there are no problems with the above, see below.

1.2 Confirm Tomcat's environment variable configuration

For the free installation version of Tomcat, when starting Tomcat, it is necessary to read the environment variables and configuration information. Without this information, the environment variables cannot be registered, resulting in a crash.
Solution:

1: Find startup.bat in the bin folder of the unzipped tomcat, right-click -> Edit. Add the following two lines to the top of the file:
Note: The following path should be copied according to your own installation path

SET JAVA_HOME=D:\jdk1.8.0_131 (java jdk directory)
SET TOMCAT_HOME=D:\Tomcat\apache-tomcat-9.0.40-windows-x64\apache-tomcat-9.0.40 (the directory of the decompressed tomcat file)

As shown in the figure:

insert image description here

2. Find shutdown.bat in the unzipped tomcat bin folder, right-click -> Edit. Add the following two lines to the head of the file:

Note: The following path should be copied according to your own installation path

SET JAVA_HOME=D:\jdk1.8.0_131 (java jdk directory)
SET TOMCAT_HOME=D:\Tomcat\apache-tomcat-9.0.40-windows-x64\apache-tomcat-9.0.40 (the directory of the decompressed tomcat file)

As shown in the figure:

insert image description here

After configuration, just click start.bat to start.

2. Port occupation problem

If you are sure that there is no problem with the environment variable configuration, the port may be occupied.
Generally, the default port of Tomcat is 8080
For Windows systems, press win+R to open cmd and enter in the command line

netstat -ano | findstr 8080

To see if there is a process currently occupying the port

insert image description here

If you can see that the port is occupied, you can use the PID (process ID) to check which program is occupying the port. Enter in the command line

tasklist | findstr PID

Note: PID is the number in the last column. Do not forget the space when entering the command.

insert image description here

After finding the process occupying the port, enter in the command line

taskkill /f /t /im process name

Note: The space before the slash means the process name is the process name just found.

insert image description here

At this point, the process occupying the port is ended. At this time, double-click start.bat and there should be no problem.

This is the end of this article on how to solve the problem of Tomcat crashing when you double-click startup.bat. For more information about Tomcat crashing when you double-click startup.bat, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Causes and solutions for the problem of Tomcat crashing when starting up.bat
  • When the Web project is packaged into a war package and Tomcat is deployed, the startup.bat is run and the deployment fails directly. A quick solution
  • Solution to the problem of Tomcat crashing after clicking startup.bat
  • Double-click to start the startup.bat in tomcat and the reason and solution
  • Possible causes and solutions for Tomcat crashing when executing startup.bat

<<:  Solve the problem of MySQL reporting Invalid default value for ''operate_time'' error

>>:  Details of various font formats in HTML web pages

Recommend

MySQL can actually implement distributed locks

Preface In the previous article, I shared with yo...

Tutorial on building nextcloud personal network disk with Docker

Table of contents 1. Introduction 2. Deployment E...

How to support Webdings fonts in Firefox

Firefox, Opera and other browsers do not support W...

HTML+CSS to achieve charging water drop fusion special effects code

Table of contents Preface: accomplish: Summarize:...

IE6 BUG and fix is ​​a preventive strategy

Original article: Ultimate IE6 Cheatsheet: How To...

Examples of using the or statement in MySQL

1. The use of or syntax in MySQL, and the points ...

Common methods of Vue componentization: component value transfer and communication

Related knowledge points Passing values ​​from pa...

Use of provide and inject in Vue3

1. Explanation of provide and inject Provide and ...

Detailed explanation of the installation process of Jenkins on CentOS 7

Install Jenkins via Yum 1. Installation # yum sou...

React+TypeScript project construction case explanation

React project building can be very simple, but if...

Sample code of uniapp vue and nvue carousel components

The vue part is as follows: <template> <...

Detailed explanation of Linux inotify real-time backup implementation method

Real-time replication is the most important way t...