tomcat启动startup.bat一闪而过问题的解决方法【亲测有效】

2025-05-26 0 25

遇到很多次运行startup.bat后,一个窗口一闪而过的问题,但是从来没去纠正怎样修改配置才是正确的,现在从网上查阅的资料整理如下:

tomcat在启动时,会读取环境变量的信息,需要一个catalina_home 与java_home的信息,catalina_home即tomcat的主目录,java_home即java安装的主目录,jdk的主目录。

首先,要在环境变量处,配置java_home,注意变量值是jdk的主目录,不是bin目录,并且不要加分号,如图:

tomcat启动startup.bat一闪而过问题的解决方法【亲测有效】

然后,如果这样配置,startup.bat还是一闪而过,可以右键点击startup.bat,编辑,在文本的最后敲上pause,保存后重新运行startup.bat,这时候窗口不会再一闪而过,而是停留在桌面上(调试成功,把pause去掉即可)。

tomcat启动startup.bat一闪而过问题的解决方法【亲测有效】

如果有错误信息,这时候会显示出来,可以再根据它的错误提示,上网搜索对应的解决办法,下面是在错误提示窗口遇到过的问题:

一、 neither the java_home nor the jre_home environment variable is defined

tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat,只要在setclasspath.bat的开头声明环境变量(红色两行)就可以了,原因是后来较新版本安装完不会自动登记环境变量java_home,jre_home。
给setclasspath.bat的开头添加红色标记部分,如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13
rem ---------------------------------------------------------------------------

rem set classpath and java options

rem

rem $id: setclasspath.bat 505241 2007-02-09 10:22:58z jfclere $

rem ---------------------------------------------------------------------------

set java_home=c:\\program files\\java\\jdk1.6.0_20

set jre_home=c:\\program files\\java\\jre6

rem make sure prerequisite environment variables are set

if not "%java_home%" == "" goto gotjdkhome

if not "%jre_home%" == "" goto gotjrehome

echo neither the java_home nor the jre_home environment variable is defined

echo at least one of these environment variable is needed to run this program

goto exit

这样在每次运行startup.bat时就自动注册了java_home,jre_home。

运行startup.bat,提示“信息:server startup in xxxxx ms” ok 大功告成。

注意了!!!!

server.xml配置文件,connector节点正确构成如下,如果这里修改过,定得仔细检查,否则启动startup.bat也会一闪而过

?

1

2

3

4
<connector executor="tomcatthreadpool"

port="8081" protocol="http/1.1"

connectiontimeout="20000"

redirectport="8444" />

tomcat启动startup.bat一闪而过问题的解决方法【亲测有效】

原文链接:https://www.cnblogs.com/xiaoyingzhanchi/p/9081171.html

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 tomcat启动startup.bat一闪而过问题的解决方法【亲测有效】 https://www.kuaiidc.com/54330.html

相关文章

发表评论
暂无评论