JDK-6834346 : java.awt.Robot could not be instantiated with DISPLAY set to Linux machine
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris
  • CPU: generic
  • Submitted: 2009-04-27
  • Updated: 2012-03-22
  • Resolved: 2009-04-27
Related Reports
Duplicate :  
Description
If DISPLAY is exported to Linux machine, the following instantiation won't be possible on Solaris:

public class Robot {
    public static void main(String[] args) throws java.awt.AWTException {
        new java.awt.Robot();
    }
}

On JDK7 it will lead to:

Exception in thread "main" java.lang.IllegalArgumentException: button doesn't exist 12
        at java.awt.event.InputEvent.getMaskForButton(InputEvent.java:233)
        at java.awt.Robot.<init>(Robot.java:101)
        at Robot.main(Robot.java:3)

Probably, other OS combinations are possible. Verified for two linix machines.

Code sample above works fine on JDK6