Wednesday, January 20, 2010

How to set the locale environment variables under Linux

The locale environment variables can affect the encoding of Java applications.
Thus, sometimes if you do not set the variables correctly, you can't run your Java applications.

You can run command "locale" to display all the locale environment variables of current shell:
$ locale
LANG=en_US.utf8
LC_CTYPE=de_DE.utf8
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=de_DE.utf8
LC_NAME=de_DE.utf8
LC_ADDRESS=de_DE.utf8
LC_TELEPHONE=de_DE.utf8
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION=en_US.utf8
LC_ALL=


You can see all the supported locale settings using:
$locale -a

The setting of LC_CTYPE seems to be decisive over all other variables except for LC_ALL. Setting LC_ALL overrides any other locale variable.

No comments: