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

报错:
tomcat启动失败,JRE_HOME和Using CATALINA_OPTS: ““反复横跳
没查出明确的结果,但是有一个说:
tomcat启动失败,JRE_HOME和Using CATALINA_OPTS: ““反复横跳
然后,我又把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
......

结果

tomcat启动失败,JRE_HOME和Using CATALINA_OPTS: ““反复横跳
在浏览器中输入链接:

http://localhost:8080

tomcat启动失败,JRE_HOME和Using CATALINA_OPTS: ““反复横跳
成功启动tomcat服务!!!!!!!
tomcat启动失败,JRE_HOME和Using CATALINA_OPTS: ““反复横跳

上一篇:vue相关笔记


下一篇:面试题心得--jdk、jre,jvm的区别?