添加tomcat开机启动服务时报错:Neither the JAVA_HOME nor the JRE_HOME enviromment variable is defined
首先,参考的 https://blog.csdn.net/wabil/article/details/78818249 的方式添加 tomcat 开机启动,这种方式不需要添加 setenv.sh 文件,轻量级,非常方便,具体方式如下:
1. 创建一个服务文件
vim /lib/systemd/system/tomcat.service 复制如下内容,修改后保存:
[Unit]
Description=tomcat
After=network.target [Service]
Type=oneshot
ExecStart=/home/apache-tomcat-7.0.70/bin/startup.sh // 自已的tomcat目录
ExecStop=/home/apache-tomcat-7.0.70/bin/shutdown.sh // 自已的tomcat目录
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes [Install]
WantedBy=multi-user.target
2. 启动服务
systemctl start tomcat.service
执行这步的时候,始终报启动失败,执行下面步骤查看失败原因。
3. 查看服务状态
systemctl status tomcat.service

没理由 JAVA_HOME 和 JRE_HOME 不存在啊,明明是存在的,检查一下发现确实是存在的:

解决方法:
方法1. 在 tomcat/bin/setclasspath.sh 中添加 JAVA_HOME 和 JRE_HOME 的指向(试了一下,不知道什么原因没搞成功)
# -----------------------------------------------------------------------------
# Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
# are valid and consistent with the selected start-up options and set up the
# endorsed directory.
# -----------------------------------------------------------------------------
#
24 # JAVA_HOME=/usr/java/jdk1.8.0_171
25 # JRE_HOME=/usr/java/jdk1.8.0_171/jre
方法2. 在 tomcat.service 中添加 JAVA_HOME 和 JRE_HOME 的指向(推荐)
Environment='JAVA_HOME=/usr/java/jdk1.8.0_171'
Environment='JRE_HOME=/usr/java/jdk1.8.0_171/jre'
此时再次执行服务启动命令 systemctl start tomcat.service 成功,服务运行状态如下:

附完整的 tomcat.service 文件
[Unit]
Description=Tomcat
After=network.target [Service]
Type=forking
Environment='JAVA_HOME=/usr/java/jdk1.8.0_171'
Environment='JRE_HOME=/usr/java/jdk1.8.0_171/jre'
ExecStart=/opt/my/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/my/tomcat/shutdown.sh
RemainAfterExit=yes [Install]
WantedBy=multi-user.target
4. 设置为开机启动
systemctl enable tomcat.service
添加tomcat开机启动服务时报错:Neither the JAVA_HOME nor the JRE_HOME enviromment variable is defined的更多相关文章
- 普通用户操作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项目适合出现这个信息,Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At ...
- python paramiko ssh.exec_command()启动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 progr
问题说明:
- Tomcat9+JDK 13报错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使用的是https://tomcat.apache.org/download-90.cgi Tomcat9 之前安装的JDK 13,有JAVA_HOME环境变量地址(C:\Program ...
- 启动tomcat 报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
[root@localhost META-INF]# systemctl start tomcat Job for tomcat.service failed because the control ...
- tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable
linux 下 启动tomcat 报: Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least o ...
- tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
windows系统: 部署了一个Tomcat8.5.15,bin目录下startup.bat执行,结果提示Neither the JAVA_HOME nor the JRE_HOME enviro ...
- Jenkins启动Tomcat时提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
Jenkins构建提示: [SSH] executing...Neither the JAVA_HOME nor the JRE_HOME environment variable is defi ...
- linux安装tomcat Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
这两天我们的开发机重启了好几次,发现每次重启后我的tomcat总是没有启动.检查java路径,配置正确,后来拿普通账号启动tomcat时报如下的错: Neither the JAVA_HOME nor ...
- Java项目启动时候报Neither the JAVA_HOME nor the JRE_HOME environment variable is defined 解决办法
今天在发布Java项目的时候又遇到 Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At leas ...
随机推荐
- Android OkHttp(1)
Android OkHttp(1) OkHttp是一个流行的第三方开源网络请求框架,在目前的一些APP开发中比较流行.Android平台开源的网络请求框架不少,比如常见的Volley, Asyn ...
- HDU 1525 Euclid Game
题目大意: 给定2个数a , b,假定b>=a总是从b中取走一个a的整数倍,也就是让 b-k*a(k*a<=b) 每人执行一步这个操作,最后得到0的人胜利结束游戏 (0,a)是一个终止态P ...
- windows PHP配置随笔
这几天配置本地windows wnmp(windows + nginx + mysql + php 5.3)遇到了不少问题.决定以后随笔记下解决的问题. #php.ini 配置含路径的值时,要注意把使 ...
- codevs——1742 爬楼梯
1742 爬楼梯 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 小明家外面有一个长长的楼梯,共N阶.小明的 ...
- JAVA生成扫描条形码
条形码是一种可视化.机器可读的数据,这些数据通常描述了携带该条码的物品的相关信息.条形码已经广泛被应用在商品流通,图书管理,邮政管理和银行系统等领域.在这篇文章中,将介绍如何生成和扫描一些常见的一维和 ...
- FTPUtil工具类
package com.xxx.common.util; import java.io.File; import java.io.FileOutputStream; import java.io.IO ...
- Ubuntu 16.04安装7zip的图形界面工具PeaZip
其实PeaZip不是7zip的图形界面工具,而是一整套方案,里面包括了7z格式的解压缩等. PeaZip Linux版本只有32位包,如果你使用的是64位Ubuntu系统,那么先打开终端运行下面的命令 ...
- Kettle循环删除数据
1.问题描述: 某个系统原库的数据同步到备份库.但是由于原库的的数据会物理删除,此时需要删除备份库的数据. 2.不理想的解决1: 1)首先从备份库获取该表的所有ID: 2)循环备份库的ID,去原库检测 ...
- 一 hadoop 相关介绍
hadoop 相关介绍 hadoop的首页有下面这样一段介绍.对hadoop是什么这个问题,做了简要的回答. The Apache™ Hadoop® project develops open-sou ...
- height not divisible by 2
height not divisible by 2 h.264 - FFMPEG (libx264) "height not divisible by 2" - Stack Ove ...