javalocaleubuntu-10.10system-setting

Where does the JVM get the locale settings in ubuntu 10.10?


My web app runs fine after I changed the system locale however whenever files are generated (java.text.numberformat.getCurrencyInstance() ) the currency shown in the files are in $ as opposed to € which is the currency for the system locale. The web application doesn't have a problem displaying the right currency though. The system is a remote ubuntu 10.10 server. I have exhhausted every system locale setting possibility and after multiple restarts I am still nowhere close to the answer. [Edit] I have tried the following:

https://askubuntu.com/questions/89976/how-to-change-the-default-locale-in-ubuntu-10-10-server when the problem initially appeared which solved the display issues.

I have purged all other locales except french using localepurge.

I have edited the /etc/default/locale to contain the following:

LANG=fr_FR.UTF-8
LANGUAGE=fr_FR
LC_CTYPE=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_COLLATE=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_MESSAGES=fr_FR.UTF-8
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

Solution

  • Even if your remote system have locale set to X, and you connect from remote host with locale set to Y your locale (Y) can be magically transferred to remote system for the current session (like TERM is).

    see SendEnv LANG LC_* in man ssh_config.

    So, your remote java app, may get different locale settings depending of how you start it. If it gets started as a system service after reboot on host A, it will get it's natural locale settings on host A (LANG="C"), but if you login from another host B via ssh, with different locale settings (LANG="pl_PL" on host B) the java app started from that ssh session on host A may get (depending on ssh configuration) locale settings from host B.

     _______________                         ______________
    [ remote host A ]                       [ local host B ]
    [ LANG="C"      ]  - - - - [ssh]- - - - [ LANG="pl_PL" ]
    [ java app      ]                       [ xterm        ]
    [_______________]                       [______________]