I need to change the default locale that java uses on a Windows 2008 Server machine. Java is installed as part of an Oracle + Application server setup. I can do this in code, but I need to permanently change this setting.
Edit: I should note that we're talking about jsp pages served via Application server so I can't exactly pass command line arguments to java. Also the machine's regional and language options are already set to what I need (Greek). Java's default locale is still en_US instead of el_GR.
Edit and solution: I was porting an existing app to a new server. The app took the default locale for granted, which didn't work out so well on the new server (it-works-on-my-machine in all its glory). I was hoping of not having to touch the code itself, but finally decided to explicitly set the default locale in-code in a file that's already included by all the pages. Not the most elegant of solutions, but wth, it works.
You should use LocaleList. getDefault(). get(0); as this will return the Locales sorted by the preferred language. Why not just use Locale.
In Java, we can use Locale. setDefault() to change the JVM default locale. Alternatively, in the command line, we can configure the user. country and user.
SystemLocale specifies the default language to use for non-Unicode programs. This setting is used by both Windows Setup and Windows Deployment Services. The system locale specifies which bitmap fonts and code pages (for example, ANSI or DOS) are used on the system by default.
That is, the JVM determines the default locale from the host environment. The host environment's locale is determined by the host operating system and the user preferences established on that system.
Would specifying the locale on the command like that starts the JVM work?
java -Duser.language=2-char-language-code -Duser.region=2-char-country-code
http://www.oracle.com/technetwork/articles/javase/locale-140624.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With