1

I need to setup a text field and it's input language to be Malayalam-India in Windows.

I tried with this code:

System.setProperty("user.language","MY"); System.setProperty("user.country","IN"); 

But it didn't succeed.

How can I set the system language in Java?

3
  • What do you expect to happen when you change the input language? Do you mean the keyboard as an input device? Commented Aug 2, 2014 at 2:27
  • You are (apparently) not trying to set the system language. The code indicates that you are actually trying to set the language for your application. Commented Aug 2, 2014 at 2:28
  • Keyboard input to a text field shoud be in Malayalam Language. How can i change to malayalam? Commented Aug 2, 2014 at 12:58

1 Answer 1

2

It should be noted that the "user.language" and "user.country" values need to be passed as VM Arguments at startup and NOT set using System.setProperty() at runtime, since System.setProperty() will not influence the default locale that is already in memory. If you need to change the default locale during runtime, use Locale.setDefault();

// THIS WON'T WORK - IF YOU NEED TO SET DEFAULT LOCALE AT RUNTIME, USE Locale.setDefault() System.setProperty("user.language","MY"); System.setProperty("user.country","IN"); 

Set Locale first and change the system propery

Locale.setDefault( new Locale("MY")); System.setProperty("user.language","MY"); Locale.setDefault( new Locale("IN") ); System.setProperty("user.language","IN"); 

Reference: http://www.avajava.com/tutorials/lessons/how-do-i-set-the-default-locale-via-system-properties.html

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.