views:

807

answers:

2

Is there a way to set/change the keyboard input language in Java (eg from English to German)?

Example Use Case: Script to be used for playback is recorded (typed in) on a German keyboard. The automated playback is done on a English keyboard...fails if keyboard is not set to German automatically before script is run.

A: 

The keyboard input map is managed entirely by the operating system on every platform that I'm familiar with. Java provides no APIs for manipulating this in a cross-platform manner. I would investigate native APIs that you could manipulate via JNA, or even (if you're feeling dirty) shelling out to call some platform-specific command which does what you need.

You're not going to find a solution within the JDK standard lib.

Daniel Spiewak
A: 

In java, you can use the InputContext class. See its API or do google search on InputContext.