Setting default locale for Tomcat Service in Windo

2020-06-08 08:39发布

问题:

I have installed Apache Tomcat 6 as a Service in a Windows XP computer (French)

My problem is that Tomcat itself and all webapps (Sonar and Hudson) now show french messages. I want English messages of course so I went to the "Regional Settings" window in Control panel and changed everything to English (US)

Tomcat however is still in French. Nothing changed at all.

I suspect that because it runs as a service it does not pick the settings from control panel.

So is there any way to trick the Tomcat JVM so that it uses English instead of French? I have sys admin access to the machine (XP PRO French)

Thank you

回答1:

You need to set user.language and user.region appropriately,

e.g.

java -Duser.language=en -Duser.region=CA

in your Tomcat startup (probably catalina.bat). Check this link for more info, and for references to the sets of valid ISO codes for the above.



回答2:

The Tomcat manager was showing up in French for me, despite the fact that I tried some of the suggestions above. The issue turned out to be browser specific. Chrome had "French" listed as one of my languages and as soon as I removed it from the list in preferences and refreshed the page, Tomcat showed up in English. I hope that will be helpful for anybody else in the future who is having this sort of problem.



回答3:

Specify language option in service parameters.

$Tomcat/bin/javaw.exe move to Java tab and specify -Duser.language=en -Duser.region=CA at Java Options:



回答4:

Regional Settings are per user and services are run as a different user (which one is used for each service can be checked in Control Panel / Administrative Tools / Services ).

So you changed the settings for the user account you used to log in, while the Tomcat service is run under a different account.



回答5:

Unfortunately, catalina.bat (or catalina.sh) is not executed by Windows when running Tomcat service, so catalina.bat modification doesn't solve this problem.

The solution is to run the service manually (or re-install the service) adding these parameters to the execution of the service. Here it's the specification of how the service must be run or installed in order to do this:

https://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html (Tomcat 6) https://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html (Tomcat 7)

According to this specification, to run Tomcat6 service establishing en_US locale, you should execute:

> $PATH_TO_TOMCAT/bin/tomcat6.exe //TS//Tomcat6 ++JvmOptions -Duser.language=en;-Duser.region=US

In the link above, there are some examples of how to install and delete the service as well.

Hope this helps!