tomcat java home is_问题:启动tomcat报找不到JAVA_HOME或者JRE_HOME环境变量的问题

一、错误来源

在非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

三、错误译文

JAVA_HOME和JRE_HOME环境变量都没有定义

运行这个程序至少需要这些环境变量中的一个

四、错误思索

我明明在/etc/profile这个文件里面添加了java和tomcat的环境变量啊,为什么还出错,而在服务器上启动tomcat就不报这个错误

五、粗略分析错误原因

在服务器上启动tomcat不报错是因为启动tomcat时区/etc/profile文件里面找到了java和tomcat的环境变量,所以顺利启动,而在外部启动tomcat时,tomcat程序首先调用startup.sh脚本文件,startup.sh又去调用catalina.sh这个脚本文件,而catalina.sh脚本文件又会去setclasspath.sh这个脚本文件里面寻找tomcat变量环境,这是因为setclasspath.sh文件就是tomcat变量环境脚本,这是因为这个脚本默认是没有在脚本开头申请java和jdk的变量环境刘静的,因此报错,setclasspath.sh的路径是:

/usr/local/tomcat/bin/setclasspath.sh

(因为我的tomcat是装在/usr/local路径下了,所以我的是这个,你们要按照你们的安装路径在查找)

六、查看setclasspath.sh脚本文件,精确分析原因

setclasspath.sh脚本原文以及中文解释如下:

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements. See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License. You may obtain a copy of the License at

#

#

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值