Based on the Stack Overflow post that was given in a comment, you can do this with fairly easily it appears.
In that post it looks like you can use
Java.awt.Robot to create an image with pixels that are taken from the screen…a screenshot. The code that they give is:
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); BufferedImage capture = new Robot().createScreenCapture(screenRect); ImageIO.write(capture, "jpg", new File(args));
Keep in mind that this is nearly 10 year old code and will only capture the primary monitor.
ImageIO.Write() method takes a parameter that allows for different image formats:
ImageIO.write(capture, "jpg", new File(args));
ImageIO takes the buffered image from the robot and writes it to a file of any format that you like.
Just change the
"jpg" to the format you want and give it a test to make sure that it works.