views:

1822

answers:

3

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.

+1  A: 

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://java.sun.com/developer/technicalArticles/J2SE/locale/

Nate
A: 

I'm not sure how to do it with Oracle's java. Does setting the java properties user.language, user.country, and user.variant work?.

Stephen Denne
A: 

In fact there are two answers I found - the WRONG one presented by http://java.com/en/download/help/locale.xml and the hack one that works.

I'll explain - I use a French-installed multi-language XP in France with a French keyboard - but I want my apps to speak to me in English. The page at Sun plain does not work with that combination - Java still talks to me in French.

The HACK solution was to go into regedit and change HKEY_CURRENT_USER\Control Panel\International\Locale from 0000040C to 00000409. That made Java talk English.

Going back to the regional settings control panel tool, I noticed that this, in fact, had changed the name in the "Regional Options" drop down, while keeping all the French formatting for numbers dates etc.

So that page at Sun is plain wrong!! Java does NOT get its default LOCALE from the settings on the advanced page, but from the settings on the Regional Options page - and THEY are very tough to change without screwing up ALL those options (i.e. you can't easily just change the language and leave the number/date/etc formatting as is).

Anyone know how to get that information to Sun???

Martin Bartlett