[英]Java environment variables under Windows 2012R2
We are trying to run Apache-Tomcat which would start / stop as a service.我们正在尝试运行 Apache-Tomcat,它将作为服务启动/停止。 However, when trying to set it up, we get error messages as for unset variables, making it impossible to set it as a service.
但是,在尝试设置时,我们会收到有关未设置变量的错误消息,因此无法将其设置为服务。 Looking at the file, and given that this is a .BAT file, as provided by the distribution, is there an easy way to set the JAVA-HOME and other required variables for Java to be set globally for the box ?
查看该文件,并且鉴于这是分发版提供的 .BAT 文件,是否有一种简单的方法可以设置 JAVA-HOME 和其他必需的 Java 变量,以便为框全局设置? Our main challenge is to get Apache-Tomcat copied / setup through a script, and the environment variables globally (and permanently) set so that when the server is rebooted, or the service started/stopped/restarted.
我们的主要挑战是通过脚本复制/设置 Apache-Tomcat,并全局(和永久)设置环境变量,以便在服务器重新启动或服务启动/停止/重新启动时。
The JAVA_HOME
environment variable is only used when running the service.bat
file. JAVA_HOME
环境变量仅在运行service.bat
文件时使用。 Once the service has been created, it has embedded the value, so changing a global JAVA_HOME
environment variable will make no difference.创建服务后,它已经嵌入了值,因此更改全局
JAVA_HOME
环境变量将没有任何区别。
When you want to use a different JAVA_HOME
value, you have to deregister the service and reregister with the new value.当您想使用不同的
JAVA_HOME
值时,您必须取消注册服务并使用新值重新注册。
This is regardless of Windows version.这与 Windows 版本无关。 Also remember to run
service.bat
"as admin".还记得以“管理员身份”运行
service.bat
。
There is a good reason why a registered Tomcat instance is not using global environment values.注册的 Tomcat 实例不使用全局环境值是有充分理由的。 As an example, we're running 6 different Tomcat instances on our UAT server, each with a different combination of Tomcat version and Java version.
例如,我们在 UAT 服务器上运行 6 个不同的 Tomcat 实例,每个实例都有不同的 Tomcat 版本和 Java 版本组合。 We couldn't do that if all the instances were using a single global
JAVA_HOME
or CATALINA_HOME
value.如果所有实例都使用单个全局
JAVA_HOME
或CATALINA_HOME
值,我们就无法做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.