Java Program to Take Screenshots

Program

import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;
 
class Snap
{
 public static void main(String args[]) throws Exception
 {
  Robot awt_robot = new Robot();
  BufferedImage Entire_Screen = awt_robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
  ImageIO.write(Entire_Screen, "PNG", new File("Entire_Screen.png"));
 }
}

the program utilizes Java.awt.Robot class to catch the screen pixels and utilizations ImageIO to spare it as PNG picture position.

Simply reorder the program in Notepad, spare it and run the program to take screenshot.

Note: The Screenshot picture will be put away at the area where your program is put away.

Leave a Comment

error: Alert: Content is protected!!