Neither the JAVA_HOME nor the JRE_HOME environment variable is defined ;At least one of these enviro...

linux下,关闭和重启tomcat时报错:

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

我的tomcat以前是正常的,突然重启下tomcat时报了这个错,错误大致是环境变量不可用造成的,

在网上找了很久都是说要修改setclasspath.bat(该文件路径在tomcat的bin目录下)文件;在文件中加入JAVA_HOME和JRE_HOME的环境变量,

我也在该文件中加了如下:

rem Make sure prerequisite environment variables are set

rem In debug mode we need a real JDK (JAVA_HOME)

export JAVA_HOME=/usr/local/jdk1.7.0_79
export JRE_HOME=${JAVA_HOME}/jre

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
"setclasspath.bat" [dos] 97L, 3509C

保存好文件,再次运行./startup.sh 

仍然报错:

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

崩溃了,网上就这么一种解决问题的方法;

突然我意识上闪出一个念头,前面使用tomcat也是正常的,会不会在linux在运行的内存里面丢失了JAVA_HOME和JRE_HOME

的环境变量参数,如果是那样,就重新写入/etc/profile环境变量就ok了。

接着我运行了#source /etc/profile

重新写入profile配置文件

运行#java -version 

奇迹出现了

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

切换到tomcat的bin目录下

运行#./startup.sh

tomcat运行成功!

转载于:https://www.cnblogs.com/hj57519153/p/5121298.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值