Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_8);
robot.keyRelease(KeyEvent.VK_8);
robot.keyRelease(KeyEvent.VK_SHIFT);
When you try to type '*' from keyboard, you pres shift+8. Same key storkes should be simulated. Similar way can be used for any special characters.