当前位置:首页 > 软件开发 > tomcat 提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 完美解决(tomcat error)

tomcat 提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 完美解决(tomcat error)

N32周前 (09-12)软件开发144

原因:

因为启动tomcat会调用tomcat安装文件中的startup.bat,而它调用了catalina.bat则调用了setclasspath.bat。因此需要在setclasspath.bat的开头手动声明环境变量。

解决方案:

用vim打开tomcat的bin目录下的setclasspath.sh,添加JAVA_HOME和JRE_HOME两个环境变量(下图红色方框内),两个环境变量路径为您安装的java JDK的路径。

此问题一般跟环境变量没有关系,一般为tomcat配置问题。

@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:\Program Files\Java\jdk1.7.0_80

set JAVA_HOME=D:\Program Files\Java\jre7


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



v2-3fd20f4b4f5c923e56f992c83cd92e0f_720w.webp.jpg

扫描二维码推送至手机访问。

文章内容摘自网络,如有侵权请联系本站删除。

本文链接:https://www.net3c.com/post/239.html

相关文章

Kafka组件介绍

Kafka组件介绍

1.Kafka的三大特点1.高吞吐量:可以满足每秒百万级别消息的生产和消费。 2.持久性:有一套完善的消息存储机制,确保数据高效安全且持久化。 3.分布式:基于分布式的扩展;Kafka的数据都会复...

Gradle sync failed: Could not GET 'https://dl.google.com/dl/android/

Gradle sync failed: Could not GET 'https://dl.google.com/dl/android/

2023/8/27 002722:12 * daemon not running; starting now at tcp:503722:12 * daemon started successfull...

Java 环境变量配置

Java 环境变量配置

1、系统变量→新建 JAVA_HOME 变量 JAVA_HOMEC:\Program Files\Java\jdk1.8.0_1912、系统变量→寻找 Path 变量→编辑(Win10系统)...

Android官方建议关于Android APP UI界面设计的一些参考原则

Android官方建议关于Android APP UI界面设计的一些参考原则

  下面是来自于Android官网给出了关于Android APP UI界面设计的一些参考原则,希望对广大ui设计师能带来帮助,尤其是在进行Andriod相关界面设计的时候。  Android安卓手机...

IDEA提示cannot connect to already running ide instance excption:process 10,232 is still running解决方案

IDEA提示cannot connect to already running ide instance excption:process 10,232 is still running解决方案

IDEA提示cannot connect to already running ide instance excption:process 10,232 is still running解决方案罢了罢...

Android studio怎么修改重命名文件名

Android studio怎么修改重命名文件名

使用的Android studio的很多的项目的文件都是通过自己进行创建成功的,创建的完成之后项目的名称或者是文件,都需要填写入文件名称,但是创建完成之后的文件名觉得不合适了,就想需要对文件名重新命名...