sudo 啟動tomcat報錯沒有java環境


 報錯:

Cannot find ./catalina.sh
The file is absent or does not have execute permission
This file is needed to run this program

原因:

沒有給bin目錄下的文件授權可執行權限:

解決方法:

chmod +x bin/*.sh

 

報錯Neither the JAVA_HOME nor the JRE_HOME environment variable is defined:

解決方法如下:

tomcat啟動腳本文件: startup.sh,     startup.sh會加載 catalina.sh ,    catalina.sh會加載setclasspath.sh   

Linux:  export JAVA_HOME=絕對路徑       Windows:   set

可以直接添加到第二行:

#!/bin/sh
export JAVA_HOME=/usr/local/java1.8
# 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

 

成功

[root@hadoop1 apache-tomcat-8.0.43]# sudo  bin/startup.sh
/home/report/apache-tomcat-8.0.43/bin/catalina.sh:行143: -Xmx1024m: 未找到命令
Using CATALINA_BASE: /home/report/apache-tomcat-8.0.43
Using CATALINA_HOME: /home/report/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /home/report/apache-tomcat-8.0.43/temp
Using JRE_HOME: /home/jdk-10.0.1
Using CLASSPATH: /home/report/apache-tomcat-8.0.43/bin/bootstrap.jar:/home/report/apache-tomcat-8.0.43/bin/tomcat-juli.jar
Tomcat started.

 

以上是在catalina.sh文件中添加的。依然存在問題,就是關閉指令運行報錯 shutdown.sh

[root@hadoop1 apache-tomcat-8.0.43]# sudo bin/shutdown.sh

/home/report/apache-tomcat-8.0.43/bin/catalina.sh:行143: -Xmx1024m: 未找到命令
Using CATALINA_BASE: /home/report/apache-tomcat-8.0.43
Using CATALINA_HOME: /home/report/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /home/report/apache-tomcat-8.0.43/temp
Using JRE_HOME: /home/jdk-10.0.1
Using CLASSPATH: /home/report/apache-tomcat-8.0.43/bin/bootstrap.jar:/home/report/apache-tomcat-8.0.43/bin/tomcat-juli.jar

./catalina.sh: 1: eval: usrjjdk-10.0.1re/bin/java: not found

 

還是顯示找不到,而且路徑 usrjdk-10.0.1jre莫名奇妙少了 '/'  。

解決方法:

把剛剛修改的 export JAVA_HOME環境變量改寫到 setclasspath.sh里面,把原先的 catalina.sh export那個刪除掉

成功解決:

[root@hadoop1 apache-tomcat-8.0.43]# sudo  bin/shutdown.sh
/home/report/apache-tomcat-8.0.43/bin/catalina.sh:行143: -Xmx1024m: 未找到命令
Using CATALINA_BASE: /home/report/apache-tomcat-8.0.43
Using CATALINA_HOME: /home/report/apache-tomcat-8.0.43
Using CATALINA_TMPDIR: /home/report/apache-tomcat-8.0.43/temp
Using JRE_HOME: /home/jdk-10.0.1
Using CLASSPATH: /home/report/apache-tomcat-8.0.43/bin/bootstrap.jar:/home/report/apache-tomcat-8.0.43/bin/tomcat-juli.jar



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM