1. 程式人生 > >Neither the JAVA_HOME nor the JRE_HOME environment variable is defined解決方案

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined解決方案

今天做專案,為了測試,我把mysql資料庫表中一個欄位值改了。重啟mysql和memcached服務後,啟動專案,發現頁面顯示的內容還是修改前的值。經過各種清理快取,(專案快取等),都沒有效果。後來觀察myeclipse中tomcat啟動過程,時間比以前偏短。雖然很多異常並不懂,我試著在dos介面開啟或關閉tomcat,報了這個異常。

通過網友的提示,瞭解到:較新版本的JDK安裝好後,不會自動等級環境變數JAVA_HOME,JRE_HOME。

Tomcat中的startup.bat呼叫了catalina.bat,而catalina.bat呼叫了setclasspath.bat。

在setclasspath開頭宣告環境變數:

rem In debug mode we need a real JDK (JAVA_HOME)
if ""%1"" == ""debug"" goto needJavaHome
set JAVA_HOME=C:/Program Files/Java/jdk1.7.0_67
set JRE_HOME=C:/Program Files/Java/jre7

rem Otherwise either JRE or JDK are fine
if not "%JRE_HOME%" == "" goto gotJreHome
if not "%JAVA_HOME%" == "" goto gotJavaHome
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

再重新啟動專案,就好了