tomcat启动失败,JRE_HOME和Using CATALINA_OPTS: ““反复横跳

在tomcat bin目录下启动cmd,输入Catalina run

最初报错:

The JRE_HOME environment variable is not defined correctly
This environment variable is needed to run this program

通过网络查找问题,说需要set JRE_HOME环境变量。
我使用的JDK版本有11,13和15,都是11以上的,这些JDK自动安装时无jre文件夹,但实际内部含两种形式的jre,需要在相应的jdk安装目录下打开命令行,输入:

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

才会显示出来。
然后我按照网上教程,在tomcat的bin目录下的setclasspath.bat中添加:

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem ---------------------------------------------------------------------------
rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
rem are valid and consistent with the selected start-up options and set up the
rem endorsed directory.
rem ---------------------------------------------------------------------------
set JRE_HOME=D:\Java_JDK\jdk-13.0.2\jre
rem Make sure prerequisite environment variables are set

rem In debug mode we need a real JDK (JAVA_HOME)
if ""%1"" == ""debug"" goto needJavaHome

rem Otherwise either JRE or JDK are fine
if not "%JRE_HOME%" == "" goto gotJreHome
if not "%JAVA_HOME%" == "" goto gotJavaHome
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
......

然后,执行以下步骤

在tomcat bin目录下启动cmd,输入Catalina run

报错:
在这里插入图片描述
没查出明确的结果,但是有一个说:
在这里插入图片描述
然后,我又把JRE_HOME语句删了,然后又开始报第一种错误,总之一直无法正常启动tomcat服务。

最后,

tomcat启动失败这篇文章中找到启示,因为11版本后的jdk默认已经安装了jre,所以,JRE_HOME设置乘和JAVA_HOME一致即可。

.....
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem ---------------------------------------------------------------------------
rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
rem are valid and consistent with the selected start-up options and set up the
rem endorsed directory.
rem ---------------------------------------------------------------------------

set JRE_HOME=D:\Java_JDK\jdk-13.0.2
rem Make sure prerequisite environment variables are set

rem In debug mode we need a real JDK (JAVA_HOME)
if ""%1"" == ""debug"" goto needJavaHome

rem Otherwise either JRE or JDK are fine
if not "%JRE_HOME%" == "" goto gotJreHome
if not "%JAVA_HOME%" == "" goto gotJavaHome
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
......

结果

在这里插入图片描述
在浏览器中输入链接:

http://localhost:8080

在这里插入图片描述
成功启动tomcat服务!!!!!!!
在这里插入图片描述

评论 31
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值