I am creating a screen capture using java.awt.Robot
under Linux with OpenJDK 11. The result on Linux is a whole black image. The same code works on Ubuntu and Windows (using another file path of course).
Any clue?
public void captureScreen() throws AWTException {
Robot robot = new Robot(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice());
BufferedImage screen = robot.createScreenCapture(new Rectangle(getDefaultToolkit().getScreenSize()));
try {
ImageIO.write(screen, "jpg", new File("/tmp/screenshot.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
}
UPDATE: The the cause of the problem lies in the combination of OpenJDK and Wayland. With Oracle JDK/JRE (13.0.1) everything works fine.