Are you running the application with a user that has access to the X server (i.e. not as root)?