I searched and found:
A recursive function that will search (starting from the root window) for a window with the desired name
Window windowWithName(Display *dpy, Window top, char *name)
{
        Window *children, dummy;
        unsigned int nchildren;
        unsigned int i;
        Window w = 0;
        char *window_name;
        if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
                return (top);
        if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
                return (0);
        for (i = 0; i < nchildren; i++)
        {
                w = windowWithName(dpy, children[i], name);
                if (w)
                        break;
        }
        if (children)
                XFree((char *) children);
        return (w);
}
You can always open a java.net.Socket to port 6000 or so and speak X11 yourself.
code that might help
reference, hope this help
NOTE: package sun.awt.x11 is no more in jdk7