windows2012服务器安装tomcat the java_home environment variable is not defined correctly

windows2012配置好环境变量之后运行java -version可以看到版本,但是执行service install命令安装tomcat服务却报the java_home environment variable is not defined correctly.遇到过两次:
1.直接在tomcat\bin目录下的setclasspath.bat文件里面增加如下内容:
rem ---------------------------------------------------------------------------
rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
rem are valid and consistent with the selected start-up options and set up the
rem endorsed directory.
rem ---------------------------------------------------------------------------
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
set JRE_HOME=C:\Program Files\Java\jdk1.8.0_131\jre

rem Make sure prerequisite environment variables are set
rem In debug mode we need a real JDK (JAVA_HOME)
保存之后运行service install成功!
2.第二次遇到这个问题,根据1同样的操作依然不行。最后解决的办法是重启电脑。至今不知何原因,若实在无法确定可以重启试试

你可能感兴趣的:(windows2012服务器安装tomcat the java_home environment variable is not defined correctly)