I am working on Java project. I need to capture screens shots of different operating systems.
String outFileName = "c:\\Windows\\Temp\\screen.jpg";
try{
long time = Long.parseLong(secs) * 1000L;
System.out.println("Waiting " + (time / 1000L) + " second(s)...");
//Thread.sleep(time);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
Rectangle screenRect = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRect);
ImageIO.write(image, "jpg", new File(outFileName));
}catch(Exception screen){}
Using the above code it is capturing the screen shots from Windows XP but it is not capturing in other operating systems. Is there any other method I need to keep to make it work in all operating systems?