Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

To capture screen shot in my java application i have write following code

Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());

BufferedImage capture = new Robot().createScreenCapture(screenRect);

ImageIO.write(capture, "png", new File("resources/img/screenshot.png"));

This is working successfully and capture screen shot but this is not working in windows 8 operating system. any one else who have face this type of problem and get soluction?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
193 views
Welcome To Ask or Share your Answers For Others

1 Answer

my application is install into the program file folder and the windows 8 not give permission to write there how i can write there now?

Do not write it there! OS manufacturers as well as Sun/Oracle have been saying for years not to write files to the application's installation directory. It is not only the wrong place to write them, but as you have discovered, does not provide write permissions for a typical Java app.

Instead put the screen-shot in user.home e.g. as seen in this answer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...