windows系統: 部署了一個Tomcat8.5.15,bin目錄下startup.bat執行,結果提示Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these envi ...
windows系統:
部署了一個Tomcat8.5.15,bin目錄下startup.bat執行,結果提示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。
解決方式:
在setclasspath.bat的開頭聲明環境變數。如圖所示:
先看Tomcat的startup.bat,它調用了catalina.bat,而catalina.bat則調用了setclasspath.bat。只要在setclasspath.bat的開頭聲明環境變數,如我的就是:
rem ---------------------------------------------------------------------------
rem Set CLASSPATH and Java options
rem
rem $Id: setclasspath.bat 505241 2007-02-09 10:22:58Z jfclere $
rem ---------------------------------------------------------------------------
set JAVA_HOME=E:\Java\jdk1.8.0_151
set JRE_HOME=E:\Java\jre8
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
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
......
這樣在每次運行startup.bat時就註冊了JAVA_HOME,JRE_HOME。控制台視窗關閉後,這兩個變數也將消失,不會再占用記憶體
linux系統:
在tomcat的bin目錄下,編輯catalina.sh文件,加入
export JAVA_HOME=/usr/local/java/jdk1.8.0_151
export JRE_HOME=/usr/local/java/jdk1.8.0_151/jre
這兩行,重新啟動就正常!
本章完,個人經驗記錄,僅供參考!
白駒過隙,當看到比你優秀的人比你還努力的時候,你也會越來越優秀,相信越努力越幸運!