Setting java locale settings
When I use the default java locale on my linux machine it comes out with the US locale settings, where do I change this so that it comes out with the correct locale?
With the user.language
, user.country
and user.variant
properties.
Example:
java -Duser.language=th -Duser.country=TH -Duser.variant=TH SomeClass
I had to control this in a script that ran on a machine with French locale, but a specific Java program had to run with en_US. As already pointed out, the following works:
java -Duser.language=en -Duser.country=US ...
Alternatively,
LC_ALL=en_US.UTF-8 java ...
I prefer the latter.
I believe java gleans this from the environment variables in which it was launched, so you'll need to make sure your LANG and LC_* environment variables are set appropriately.
The locale manpage has full info on said environment variables.
You could call during init or whatever Locale.setDefault() or -Duser.language=, -Duser.country=, and -Duser.variant= at the command line. Here's something on Sun's site.