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

4

5

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.

Humbuggery answered 10/7, 2009 at 13:12 Comment(2)
Windows Control Panel > Regional and Language optionsWellintentioned
Did you restart the server? Why do you need to change it anyway - you can serve content in any locale?Wellintentioned
H
7

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

Hargrave answered 10/7, 2009 at 13:20 Comment(0)
J
6

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???

Jehias answered 12/12, 2009 at 0:30 Comment(0)
J
4
  1. user.language and user.country work, you can try the following examples:

    java -Duser.language=sv -Duser.country=SE
    java -Duser.language=en -Duser.country=US

  1. If you want jvm to select it by default, you should set environment variable JAVA_TOOL_OPTIONS, it works on windows too (except that setting environment variable is a little different on windows)!

    export JAVA_TOOL_OPTIONS="-Duser.language=en -Duser.country=US"

Please refer to this question for details of JAVA_TOOL_OPTIONS.

Johen answered 25/10, 2017 at 2:36 Comment(0)
L
3

For me changing the HKEY_CURRENT_USER\Control Panel\International\LocaleName to en-US did the trick. Changing the Locale as Martin Bartlett suggested didn't help.

Lythraceous answered 16/1, 2015 at 14:0 Comment(1)
just does not work for me, windows 10, jdk1.8.0_211Lobo

© 2022 - 2024 — McMap. All rights reserved.