Life is Elsewhere
Life is Elsewhere

Reputation:

Changing Keyboard Input language in Java

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.

Upvotes: 1

Views: 5112

Answers (2)

Vlad
Vlad

Reputation:

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

Upvotes: 0

Daniel Spiewak
Daniel Spiewak

Reputation: 55123

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.

Upvotes: 1

Related Questions