In actual development, it is generally eclipse+tomcat (perhaps the plug-in of tomcat will also be used). We only need to click the button on the servers in eclipse to start tomcat successfully.
But if you want to double-click startup.bat in the installation directory of tomcat, it will flash by. Why is this (tomcat failed to start), I will show you the specific reasons immediately.
method/step
-
Let me first confirm with you the preconditions for the problem (native version java: 1.6.20, tomcat: 6.0.32)
1) It is normal to start tomcat in eclipse.
2) Various environment variables are configured in the system as follows:
JAVA_HOME:H:\DevelopTools\Java\jdk1.6.0_20
CATALINA_BASE:H:\DevelopTools\apache-tomcat-6.0.32
CATALINA_HOME:H:\DevelopTools\apache-tomcat-6.0.32
CLASSPATH:.;%JAVA_HOME%;%JAVA_HOME%\jre\lib;
PATH:.;%JAVA_HOME%\bin;%CATALINA_HOME%\bin;
-
Let's analyze the causes and solutions of the problem in detail:
Enter the installation directory of tomcat (that is, the place where it is placed after decompression):
See the 3 bat files circled in red. Generally, when starting tomcat through startup.bat, the process is: startup->catalina->setclasspath->catalina
If there is an error in one of the three bat files, the startup fails. In order to find the reason for the flash, we need to take a look at what is in these 3 files
-
First, open startup.bat in Notepad and find the last sentence: :end, we know that end means end, :end is a mark, we add a pause (meaning to pause and wait) after it;
Execute startup.bat again, and you will see as shown in the figure. When we press any key, the cmd window flashes by again. But this has confirmed that our environment variables are all correct.
-
In order to see the information in more detail, let's change another sentence: find call "%EXECUTABLE%" start %CMD_LINE_ARGS% and replace start with run in it.
Let's take a look at the error message output in the cmd window:
error occurred during initialization of vm
could not reserve enough space for object heap
could not create the java virtual machine
We can generally understand it as: because the program does not request enough memory during initialization, the vm program exits.
So now that we have found the cause of the problem, we can solve this problem: just apply for enough memory
Do as follows: In catalina.bat, find the command under Execute The Requested Command
set JAVA_OPTS replace this sentence with:
set JAVA_OPTS= -server -Xms800m -Xmx800m -XX:MaxNewSize=256m
There are actually many ways to replace the sentence set JAVA_OPTS, but they are generally the same
Start startup.bat again and you will see the long-awaited screen.
Started successfully!
Original address: http://jingyan.baidu.com/album/546ae18563bacd1149f28cca.html?picindex=1