To make it short and sweet, here it is. Looking to do a simple screenshot on the client-side (and if anyone would be so kind, point me in the direction to create an automated upload of the screen to a server. ++ if you can provide a tip on doing this at an interval)..
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ScreenShot {
/**
method to capture screen shot
@param String uploadPath to save screen shot as image
@returns boolean true if capture successful else false
*/
boolean captureScreenShot(String uploadPath)
{
boolean isSuccesful = false;
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage capture;
try {
capture = new Robot().createScreenCapture(screenRect);
// screen shot image will be save at given path with name "screen.jpeg"
ImageIO.write(capture, "jpg", new File( uploadPath, "screen.jpeg"));
isSuccesful = true;
} catch (AWTException awte) {
awte.printStackTrace();
isSuccesful = false;
}
catch (IOException ioe) {
ioe.printStackTrace();
isSuccesful = false;
}
return isSuccesful;
}
}
Here's what I did: Took the screenshot java file made from above and compiled it, but here's the error I get when I try to run the class in java..
java ScreenShot
" Exception in thread "main" java.lang.NoSuchMethodError: main "
What is going wrong? And I'm a little confused with the upload path part, is that a constant, a placeholder prompting the user to submit a string, can that designation be pointed to a server?
Thanks to all that can help. : )