2

I want to view a photo using Windows Photo Viewer ... I'm using ProcessBuilder to do that, but the compiler does not accept this . I tried typing mspaint instead of windowsphotoviewer and it worked. So how can i do that ? here is the line of code i tried:

Process photo = new ProcessBuilder("mspaint","Capture.PNG").start();

Thank you very much for your help :)

Robin Green
  • 32,079
  • 16
  • 104
  • 187
Saad_Hasan
  • 39
  • 7

1 Answers1

1

This should work fine for mspaint.

String path = "D:\\imgfolder\\img.jpg";
String expr = "mspaint " + path;
Runtime.getRuntime().exec(expr);

This should work fine for Windows photo viewer

String path = "D:\\imgfolder\\img.jpg";
String expr = "rundll32 \"C:\\Program Files (x86)\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen " + path;
Runtime.getRuntime().exec(expr);
bluelurker
  • 1,353
  • 3
  • 19
  • 27