Before executing of command you should perform focus on input field (click on it, for example).
Then, you could execute next java code:
String [] args = {"cmd", "start", "adb", "-s", your_device_uid, "shell", "input", "text", your_text};
Runtime runtime = Runtime.getRuntime();
runtime.exec(args);