bookmark_border(Win 7) How to really change your default locale for Java

Since I could not find an easy solution for this problem I have decided to blog about this.

Lets say your machine (running Windows 7) is running in a Dutch locale. If you install the JDK and request the default locale in your application you will get: nl_NL

I’m testing this with the following code:

import java.util.Locale;

public class DefaultLocaleTester {

	public static void main(String[] args) {
		Locale defaultLocale = Locale.getDefault();
		System.out.println("Default locale is : " + defaultLocale);
	}
}

Lets say I want to make this return en_US. The official docs of Oracle say that you should change your system settings:

– go to Control Panel
– go to Region and Language
– go to tab “Administrative”
– click “Change system locale”
– change to locale you want
– restart and you’re done!

So we do this, and we run the test application again.

You will found out, this will not work. When I rerun the test application I still got nl_NL.

On stackoverflow someone had the answer to this problem. You should be changing your Format instead. So:

– go to Control Panel
– go to Region and Language
– go to tab “Formats” (is default selected)
– change language in Formats dropdown to the locale you want

Now re-run the test code, and you’ll see it will be using the locale you want.

Thanks to Martin Bartlett on Stackoverflow for his answer!