How can I change the input method in a Java program on Linux?

I am writing a Java application in which I need to be able to change the input languages ​​(for example from English to Japanese) at the request of the user. Usually the user just goes into Windows / Linux system settings and changes it there. However, for this particular application, the user will not have access to these menus.

I've done quite a bit of research on SO and elsewhere. The solutions found show the use of the method InputContext.selectInputMethod([locale])

. This works on Windows (using an IME in the Windows Registry), but I cannot get it to work on Linux (it always returns false, even when I select the locale for which I have the appropriate language packs installed).

Ideally, I would like to have a completely platform independent implementation, but at least I need it to work on Linux. So what am I missing? Do I need to install input methods as an extension? Are there any built-in IMEs that I can use? It looks like it would be tricky to implement, but I found surprisingly little specific information.

Thanks in advance for your feedback!

+3


source to share





All Articles