The nice thing about the Java library is that a lot of it is opensource. A quick glance through it shows that on Unix-ish platforms it creates a XToolkit
and then there's a lot of interfacing with the X11 library to send keyboard and mouse events.
In particular, all of the events are eventually dispatched to sun.awt.X11.XRobotPeer, who then dispatches them to awt_Robot.c who then calls various X11 functions to produce particular events.