ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

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

2021-09-20 12:30:06  阅读:1781  来源: 互联网

标签:JRE CATALINA JAVA tomcat License set rem HOME


在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服务!!!!!!!
在这里插入图片描述

标签:JRE,CATALINA,JAVA,tomcat,License,set,rem,HOME
来源: https://blog.csdn.net/weixin_46417474/article/details/120389863

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有