tomcat9 zip package installation

Table of contents

download

Configure environment variables

Solve nor the JRE_HOME problem (modify setclasspath.bat)

Solve the problem of nor the JRE_HOME (add jre environment variables separately)

Solve the tomcat garbled problem


download

Official website address: Apache Tomcat official website

 

Configure environment variables

Unzip the compressed package, unzip the decompressed file to a path without a Chinese directory: then configure the environment variable:

 

 Click OK and try tomcat, can you get up! It was found that the two startup methods are not working.

 

Solve nor the JRE_HOME problem (modify setclasspath.bat)

Method 1: Use the command line to start tomcat

Method 2: Double-click startup (no response at all after double-clicking)

 When using the command line window, you can still know what is wrong. There is no jre environment variable. When we install jdk, we usually simply install the jdk environment and will not configure the relevant jre environment, but tomcat needs this Environment variables, so there is a problem, there are two solutions :

First of all, I know why this tomcat needs this jre environment variable: tomcat is started by calling startup.bat, and this program actually calls another batch, which is the file setclasspath.bat.

 The following code is a scripting language:

So the first way is to manually specify the jre path directly in this setclasspath; however, since I am using jdk11, the downloaded jdk actually does not have a jre directory after decompression, and needs to be manually generated by myself: (After the test later, this step It can be omitted (it can be skipped but it is recommended to look at it) , because jdk11 and later default jre and jdk are in the same directory, so there is no need to configure jre additionally, but jre_home needs to be set to jdk directory. Just configure one more environment variable)

This is my jdk directory, there is no jre folder in it;

 

 Cmd in this directory, and then execute the following command: If there is no error in the console, it means the export is successful

bin\jlink.exe --module-path jmods --add-modules java.desktop --output jre

 Then add your own jre environment variable in the setclasspath just now.

Then it still reports an error, as follows: Using CATALINA_OPTS: ""

Then I checked some information and found that after jdk11, the default jre directory is the same directory as jdk (found on an online blog) and then I deleted /jre:

The configuration becomes set JRE_HOME=E:\java\jdk11\java11\jdk-11.0.4_windows-x64_bin\jdk-11.0.4

Then cmd executes startup and it succeeds, but garbled characters are found!

 Browser access: http://localhost:8080 The following image appears to indicate success;

Solve the problem of nor the JRE_HOME (add jre environment variables separately)

In order to ensure the accuracy of the test, I first deleted the set JRE_HOME=E:\java\jdk11\java11\jdk-11.0.4_windows-x64_bin\jdk-11.0.4 that I just added in setclasspath.bat.

We also said just now that jre and jdk are in the same directory by default in jdk11 and later, so there is no need to configure jre additionally, but you need to set jre_home to the directory of jdk, just configure one more environment variable .

 The path in this system variable can be configured or not. I have tested it, and it can run successfully with or without it!

 After the configuration is complete, double-click startup: success!

Solve the tomcat garbled problem

The character set encoding used by our computer is almost GBK, but after we open the tomcat configuration file, we find that the output encoding set of the tomcat console is utf-8, so of course there will be garbled characters, we only need to modify one side here The encoding set is fine, here we choose to modify the encoding set of tomcat:

 

Then restart tomcat:

 

Guess you like

Origin blog.csdn.net/weixin_53142722/article/details/126275346