zoukankan      html  css  js  c++  java
  • Tomcat之the jre_home environment variable is not defined correctly this environment variable is need

    参考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:Jdk8jdk1.8.0_101
    set JRE_HOME=D:Jdk8jdk1.8.0_101jre

    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%injava.exe" goto noJavaHome
    if not exist "%JAVA_HOME%injavaw.exe" goto noJavaHome
    if not exist "%JAVA_HOME%injdb.exe" goto noJavaHome
    if not exist "%JAVA_HOME%injavac.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%injava.exe" goto noJreHome
    if not exist "%JRE_HOME%injavaw.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%injava.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%injdb.exe"
    :gotRunJdb

    goto end

    :exit
    exit /b 1

    :end
    exit /b 0

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

  • 相关阅读:
    [King.yue]Ext.net 页面布局Flex
    [King.yue]Ext.net 弹出Windows窗体注意的事项
    [Irving]SqlServer 标量函数 详解【转】
    [Andrew]Ext.net前台弹框
    [King.yue]Ext中Grid得到选择行数据的方法总结
    [zouxianghui] 清空GridPanel的checkbox选中行
    [BILL WEI]SQL 存储过程学习
    [Tommas] 测试场景 VS 测试用例 哪个更好?(转)
    winform 打印小票
    html5 input 标签
  • 原文地址:https://www.cnblogs.com/lijingran/p/9092212.html
Copyright © 2011-2022 走看看