Tomcat之the jre_home environment variable is not defined correctly this environment variable is need

2023-05-16

         在win10上明明已经安装了JDK1.8并设置好了JAVA_HOME和JRE_HOME,可偏偏Tomcat在启动过程中找不到并且在启动startup.bat时闪退。

         先要找出问题的原因:右键编辑打开“startup.bat"文件,然后找文件的最后一行代码是:end    在:end的后面输入pause如下图所示:


接下来在DOS命令窗口运行startup.bat,此时提示报错信息如下:the jre_home environment variable is not defined correctly this environment variable is need?

原因知道了,下面来看解决办法:

1、分析startup.bat启动脚本:发现其调用了catalina.bat,而catalina.bat调用了setclasspath.bat

2、在setclasspath.bat的头部定义了JAVA_HOME和JRE_HOME的值,那么这里需要我们手动设置JAVA_HOME变量和JRE_HOME变量(红色代码为新添加)

注意:你所设置的变量要和自己的电脑中”环境变量“里的JAVA_HOME和JRE_HOME保持一致,我的是红色的代码。

@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 JAVA_HOME=D:\tomcat\apache-tomcat-7.0.65
set JRE_HOME=D:\Jdk8\jdk1.8.0_101\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

:needJavaHome
rem Check if we have a usable JDK
if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
set "JRE_HOME=%JAVA_HOME%"
goto okJava

:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly.
echo It is needed to run this program in debug mode.
echo NB: JAVA_HOME should point to a JDK not a JRE.
goto exit

:gotJavaHome
rem No JRE given, use JAVA_HOME as JRE_HOME
set "JRE_HOME=%JAVA_HOME%"

:gotJreHome
rem Check if we have a usable JRE
if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome
if not exist "%JRE_HOME%\bin\javaw.exe" goto noJreHome
goto okJava

:noJreHome
rem Needed at least a JRE
echo The JRE_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto exit

:okJava
rem Don't override the endorsed dir if the user has set it previously
if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir
rem Set the default -Djava.endorsed.dirs argument
set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed"
:gotEndorseddir

rem Don't override _RUNJAVA if the user has set it previously
if not "%_RUNJAVA%" == "" goto gotRunJava
rem Set standard command for invoking Java.
rem Also note the quoting as JRE_HOME may contain spaces.
set _RUNJAVA="%JRE_HOME%\bin\java.exe"
:gotRunJava

rem Don't override _RUNJDB if the user has set it previously
rem Also note the quoting as JAVA_HOME may contain spaces.
if not "%_RUNJDB%" == "" goto gotRunJdb
set _RUNJDB="%JAVA_HOME%\bin\jdb.exe"
:gotRunJdb

goto end

:exit
exit /b 1

:end
exit /b 0

3、添加变量后保存,并关闭文件,重新启动tomcat,然后在浏览器中敲入http://localhost:8080验证。显示如下图所示的界面则为修改成功,tomcat登录也就成功了。



本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Tomcat之the jre_home environment variable is not defined correctly this environment variable is need 的相关文章

随机推荐

  • My uBlock static filters

    My uBlock static filters 2022 百度 2022 06 https pan baidu com pan baidu com bpapi analytics pan baidu com rest 2 0 pcs ad
  • conda安装包报错:The current user does not have write permissions to the target environment(当前用户没有写入权限)

    问题 xff1a 在Winodws 10下使用conda安装第三方包时报错 xff1a EnvironmentNotWritableError The current user does not have write permissions
  • CCF 201809-3元素选择器

    分析 xff1a 这题超级坑 xff0c 当时考试时只得了50分 xff0c 现在重新做一直卡在80分 xff0c 各种复杂情况都考虑到了 xff0c 还是不能ac xff0c 于是尝试三种不同办法解决 xff0c 也均不能AC xff0c
  • 【开发经验】通过ffmpeg进行视频剪辑

    文章目录 前言一 视频剪辑1 1 生成标题2 文字和背景图叠加3 视频切割4 视频和背景图叠加结果演示java执行cmd指令更多ffmepg指令 前言 突然发现抖音有有一些人发布电视剧的精彩片段 xff0c 并且还获得了很多的点赞 突然发现
  • IE11离线安装总是提示“获取更新”的解决方法

    微软下载的IE11离线包在安装前 xff0c 必须要先安装必备更新 首先 xff0c 先检查操作系统 xff0c XP系统是无法安装IE11的 xff0c XP支持的最高版本为IE8 xff0c 如果是XP系统 xff0c 请先升级到WIN
  • debian系列linux 启动后黑屏,只有一个光标

    重复的按ctrl 43 alt 43 F1 一直到光标消失 如果跳出一个客户端登录的话就再重复按一下上面介绍的组合键 过一会儿就开机了
  • 抖音流行的字符视频如何实现

    前几天 xff0c 有个朋友给我分享了一个抖音短视频链接 xff0c 是以代古拉k跳舞视频为原型的字符视频 xff0c 朋友问我 xff1a 这个你知道怎么做吗 xff1f 我们都知道视频是由一帧一帧的静态图片组合而成的 xff0c 所以当
  • ANR系列(三)——ANR分析套路

    前言 在懂得了ANR的发生原理和监控原理之后 xff0c 是时候针对项目中的ANR进行分析了 xff0c 在分析前要知道ANR的分析套路一般是怎么分析的 分析ANR问题需要哪些日志 Trace日志 xff1a 当ANR产生的时候 xff0c
  • java socket学习笔记(一)——单线程实现socket通信

    服务器端 span class hljs keyword public span span class hljs keyword class span serverDemo span class hljs keyword public sp
  • Backtrace 分析

    xfeff xfeff 1 Java Backtrace 从Java Backtrace 我们可以知道当时Process 的虚拟机执行状态 Java Backtrace 依靠SignalCatcher 来抓取 Google default
  • docker搭建grafana+loki+promtail日志收集系统

    文章目录 docker搭建grafana 43 loki 43 promtail日志收集系统1 拉取镜像2 loki搭建1 xff09 新建配置文件2 xff09 启动容器 3 promtail搭建1 xff09 新建配置文件2 xff09
  • 微信 Mac 内测版(2.3.0)

    微信 Mac 内测版 2 3 0 WeChat for Mac 微信 Mac 版 极致简洁 迅捷沟通 微信内测版本 2 3 0 For macOS Sierra 10 12 or later 适用于 OS X 10 11 El Capita
  • 第1步 数据预处理

    文章目录 前言一 安装依赖环境二 导入依赖包三 导入数据集保姆级操作演示 xff1a 四 处理丢失数据保姆级操作演示 五 解析分类数据保姆级操作演示 六 拆分数据集为训练集合和测试集合七 特征缩放总结 前言 一 安装依赖环境 开始之前 xf
  • 深度学习-CV方向基本原理

    算法 一 卷积 卷积的基本含义 本质上就是相乘求和功能上拥有数据过滤和增强作用对于相乘求和 xff0c 是通用的使用卷积核每个像素点与对应的像素点相乘得到的结果求和作为中心点Result对于分类 xff1a 在深度学习上分一维二维三维卷积一
  • npm ERR! code ELIFECYCLE的解决

    在使用npm run dev启动程序时 xff0c 报出如下错误 xff1a npm ERR code ELIFECYCLE npm ERR errno 1 npm ERR datav jiaminghi com 64 2 0 0 dev
  • Transformer-Attention is all you need 学习笔记

    目录 摘要 xff1a 1 Introduction 2 Background 3 Model Architecture 3 1 编码器和解码器堆栈 3 2 注意力 3 2 1 Scaled Dot Product Attention 3
  • Transformer模型-学习笔记

    根据文献Attention is All you need 和The Illustrated Transformer中提出的Transformer模型进行学习整理 目录 1 Transformer 概览 2 引入张量 3 Self Atte
  • NLP中隐性语义分析及奇异值分解(SVD)-学习笔记

    目录 1 隐性语义分析 2 奇异值分解 2 1 左奇异向量U 2 2 奇异值向量S 2 3 右奇异值向量V T 2 4 SVD矩阵的方向 2 5 主题约简 1 隐性语义分析 隐形语义分析基于最古老和最常用的降维技术 奇异值分解 SVD SV
  • HTML中实现VLC播放器并对播放器进行控制

    由于在项目中 xff0c 涉及到对C 中WebBrowser控件的应用 xff0c 要求是在WebBrowser中嵌入一个带有视频的HTML网页 WebBrowser在C 中默认的是IE浏览器 xff0c 且版本比较低 xff0c 因此要对
  • Tomcat之the jre_home environment variable is not defined correctly this environment variable is need

    在win10上明明已经安装了JDK1 8并设置好了JAVA HOME和JRE HOME xff0c 可偏偏Tomcat在启动过程中找不到并且在启动startup bat时闪退 先要找出问题的原因 xff1a 右键编辑打开 startup b