参考https://blog.csdn.net/qq_30507287/article/details/53981851

今天在服务器的tomcat上部署.war文件,双击startup闪退,然后在tomcat/bin目录下,shift+右键,打开命令行窗口,然后把startup.bat拖进命令行窗口,回车,出现“jre_home environment variable is not defined correctly this environment variable is need”问题

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

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

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:\Jdk8\jdk1.8.0_101
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登录也就成功了。

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

  1. JRE_HOME environment variable is not defined correctly This environment variableis needed to run this program

    已经安装了JDK1.7 和对应JRE 安装了tomcat8 都是解压版 并设置了JAVA_HOME.JRE_HOME 但Tomcat在启动过程中找不到 错误: the JRE_HOME environ ...

  2. The JRE_HOME environment variable is not defined correctly This environment

    昨天启动tomcat还好好的,今天不知道抽什么风,cmd中报错: The JRE_HOME environment variable is not defined correctly This env ...

  3. 【基础笔记】tomcat安装后运行出现出现问题(the JRE_HOME environment variable is not defined correctly This environment variabl)

    之前装好tomcat后正常运行  后来重装系统后,又一次配置环境时却报错. 在网上查找了两篇文章. https://blog.csdn.net/haleyliu123/article/details/ ...

  4. tomcat闪退无法启动 the catalina_home environment variable is not defined correctly this environment variable is needed to run this program

    未成功配置CATALINA_HOME 1.计算机>属性>环境变量, 新建环境变量.变量名为CATALINA_HOME ,变量值tomcat的解压目录,注意后面不用多加“\”或者“;” 2. ...

  5. [Tomcat]The JRE_HOME environment variable is not defined correctly

    在tomcat的bin目录下,双击startup.bat,闪一下,就没了,后来仔细看了一下黑屏闪的内容如下: the JRE_HOME environment variable is not defi ...

  6. 【TOMCAT启动异常】The BASEDIR environment variable is not defined correctly

    <span style="font-size:18px;">The BASEDIR environment variable is not defined correc ...

  7. tomcat 环境变量配置 解决 The CATALINA_HOME environment variable is not defined correctly

    文章目录 问题描述 解决方案 问题描述 已经配置好了JAVA_HOME,CLASSPATH,Path等系列环境变量,且正确配置了CATALINA_HOME值为D:\apache-tomcat-7.0. ...

  8. TOMCAT-报错The BASEDIR environment variable is not defined correctly

    <span style="font-size:18px;">The BASEDIR environment variable is not defined correc ...

  9. maven错误The JAVA_HOME environment variable is not defined correctly

    晚上,当我准备将好的spring boot通过mvn clean package 打包成jar文件上传到linux服务器时,却在打包过程中出现了错误: C:\>mvn -version The ...

随机推荐

  1. KVM技术

    今天是周六,看到一片KVM相关的文章,感觉写得很不错,翻译了,原文在这里:KVM Technology 在开放服务器虚拟化的应用方面,KVM虚拟化技术近年来广受关注.自从2006年10月份诞生以来,其 ...

  2. 话说Session

    Session这个概念,对于搞软件的来说,再熟悉不过了.就拿我来说,Hibernate, Shiro, Spring, JSP, Web Server等等,全都涉及到Session. 不怕笑话,一直都 ...

  3. Error: Cannot find module 'webpack'错误解决

    $ npm install webpack -g $ npm install webpack-cli -g 全局安装webpack $ npm run dev Error: Cannot find m ...

  4. 兼容最新firefox、chrome和IE的javascript图片预览实现代码

    这篇文章主要介绍了兼容最新firefox.chrome和IE的javascript图片预览实现代码,测试了浏览器firefox6.firefox12.chrome 25.0.1364.172 m.IE ...

  5. java socket InputStream和OutputStream

    从java socket对象获取的InputSteam的read方法其实是对linux的recv()函数的调用,OutputStream也同理. 也就是说,InputStream和OutputStre ...

  6. git 的安装

    git在开发中已经成了必备工具了,我们来看看git在各个平台上的安装 1.Linux上安装git $sudo apt-get install git 2.mac上安装 1)homebrew安装git ...

  7. aop学习总结三----aop的相关概念

    aop学习总结三----aop的相关概念 public Object invoke(Object proxy, Method method, Object[] args) throws Throwab ...

  8. 对ShortCut和TWMKey的研究

    TWMKey = packed record Msg: Cardinal; CharCode: Word; Unused: Word; KeyData: Longint; Result: Longin ...

  9. ubuntu搭建mysql

    步骤1 – 安装MySQL 在 Ubuntu 16.04 中,默认情况下,只有最新版本的 MySQL 包含在 APT 软件包存储库中.在撰写本文时,那是 MySQL 5.7 要安装它,只需更新服务器上 ...

  10. UITextInputMode类的使用

    转载请注明:http://blog.sina.com.cn/s/blog_69081e060100v7ad.html   UITextInputMode大家看了是不是有些陌生呢?这个类是在4.2之后才 ...