How to Capture screenshot using java

import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;

public class ScreenCapture {
	public static void main(String[] args) throws Exception{
		Robot robot = new Robot();
		Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
		BufferedImage screen = robot.createScreenCapture(rectangle);
		ImageIO.write(screen, "JPG", new File("C:\\Users\\sekharbabub\\Desktop\\Screen.jpg"));


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s