Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set language in Java?

Tags:

java

I am using a Java program with foreign operating system (Korean/Japanese etc.) The display of swing components such as FileChooser is in the foreign langauges, which I need to change to English.

java.util.Locale.setDefault(java.util.Locale.ENGLISH);

JFileChooser chooser = new JFileChooser();

chooser.setLocale(Locale.ENGLISH);

And the file chooser still shows everything - buttons etc. in these foreign langauges. Any idea how to fix it?

My JFilechooser's button's OK/CANCEL are showing in Japanese. I'm using Japanese Windows. How to change that to English?

like image 559
Mr. Zen Avatar asked Jun 10 '11 10:06

Mr. Zen


People also ask

How can I change the language of Java?

Go to app > res > values > right-click > New > Value Resource File and name it as strings. Now, we have to choose qualifiers as Locale from the available list and select the language as Hindi from the drop-down list. Below is the picture of the steps to be performed.

What is Java locale?

The Java Locale class object represents a specific geographic, cultural, or political region. It is a mechanism to for identifying objects, not a container for the objects themselves. A Locale object logically consists of the fields like languages, script, country, variant, extensions.

How will you use a specific locale in Java?

Locale Class is used to perform locale task and provides locale information for the user. Constructors : Locale(String L): Creates Locale form the given language code. Locale(String L, String C): Creates Locale form the given language, country code.


1 Answers

You can specify language when you start the VM.

java -Duser.language=en -Duser.country=US -Duser.variant=US MainClass

like image 53
Kaj Avatar answered Sep 20 '22 11:09

Kaj