linux安装tomcat Neither the JAVA_HOME nor the JRE_HOME environment variable is defined

2018-01-03 19:20:18

这两天我们的开发机重启了好几次,发现每次重启后我的tomcat总是没有启动。
检查java路径,配置正确,后来拿普通账号启动tomcat时报如下的错:

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

 
原来是我使用的jdk不是通过yum安装的,是我从官网直接下载的,虽然我修改了java_home,但不太智能的tomcat仍然没有自动识别出java_home路径。

解决方法:
编辑文件 /usr/local/tomcat/bin/catalina.sh (根据你自己的jdk路径进行修改) 在文件的正文开头,即正式代码前,大概在99行添加如下代码

1export JAVA_HOME=/usr/local/jdk
2export JRE_HOME=/usr/local/jdk/jre

修改后大概是下面的样子

view source

01# $Id: catalina.sh 1202062 2011-11-15 06:50:02Z mturk $
02# -----------------------------------------------------------------------------
03
04export JAVA_HOME=/usr/local/jdk
05export JRE_HOME=/usr/local/jdk/jre
06
07# OS specific support.  $var _must_ be set to either true or false.
08cygwin=false
09darwin=false
10os400=false
11case "`uname`" in
12CYGWIN*) cygwin=true;;
13Darwin*) darwin=true;;
14OS400*) os400=true;;
15esac .....................

 

注意:Windows下请修改对应的 catalina.bat


  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

  • 2017-11-19 00:17:51

    Java如何获取Date的“昨天”与“明天”示例代码

    最近在做项目的时候用到Date和Calendar比较多,而且用到的方式也比较全,突然想到一个问题,Java如何获取Date的"昨天"与"明天",也就是前一天和后一天呢?思考后写出了方法,想着万一以后用到,就总结出来,也方便有需要的朋友们参考借鉴,下面来一起看看吧。