Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I permanently change java's default locale on Windows

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.

like image 761
Manos Dilaverakis Avatar asked Jul 10 '09 13:07

Manos Dilaverakis


People also ask

How do I make default locale?

You should use LocaleList. getDefault(). get(0); as this will return the Locales sorted by the preferred language. Why not just use Locale.

How do I change the default locale in JVM?

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.

What is default system locale?

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.

How does JVM determine default locale?

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.


1 Answers

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

like image 101
Nate Avatar answered Sep 21 '22 02:09

Nate