If for whatever reason you want to set the locale in Tomcat you simply need to add two jvm arguments in the catalina.sh
file found in the bin
directory of the Tomcat installation. I was able to set the default locale for Tomcat to US/en
on a Mac running Mac OS X Leopard with Tomcat 7.0.8 installed. These instructions should work for any *nix machine as well as later versions of Tomcat, but I can’t guarantee it. If you’re using Windows, these instructions are probably also relevant, but you would change the catalina.bat
file instead.
Step 1: Open catalina.sh
Find the file called catalina.sh
in the bin
folder of the Tomcat installation with any text editor.
Step 2: Find JAVA_OPTS=
Search for JAVA_OPTS=
in the file and in particular locate the following lines of code:
1 2 3 4 5 |
if [ -z "$LOGGING_MANAGER" ]; then JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" else JAVA_OPTS="$JAVA_OPTS $LOGGING_MANAGER" fi |
Step 3: Append the Locale JVM properties
At the end of the JAVA_OPTS
definitions add -Duser.language=en -Duser.region=US. You can of course chose any available locale and region settings you need and not just US/en
.
1 2 3 4 5 |
if [ -z "$LOGGING_MANAGER" ]; then JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Duser.language=en -Duser.region=US" else JAVA_OPTS="$JAVA_OPTS $LOGGING_MANAGER -Duser.language=en -Duser.region=US" fi |
Step 4: Save and Restart
Save the file and restart Tomcat.
Subscribe To Our Newsletter
Join our low volume mailing list to receive the latest news and updates from our team.