You are here:

Java/Windows Picture Viewer


Hi Artemus,
I'm trying to open images in the Windows Fax and Picture viewer, but have run into a problem.
While this works:

Runtime.getRuntime().exec("rundll32.exe C:\\WINDOWS\\System32\\shimgvw.dll,ImageView_Fullscreen "
         + "C:\\Eclipse\\Project1\\001.jpg");,
the finished program will be run from a DVD\CD, so I'll need to access the directory by using System.getProperty("user.dir").
After iterating along the string produced by that call, and creating a String Builder object by appending the extra '\'s and the file name and then converting that toString I get the finalString:
C:\\Eclipse\\Project1\\001.jpg. However, this: " Runtime.getRuntime().exec("rundll32.exe C:\\WINDOWS\\System32\\shimgvw.dll,ImageView_Fullscreen " finalString) doesn't work. What am I doing wrong?
with thanks.

First, you shouldn't need to append the extra \, that is only for literal Strings. E.g.

String s = "This is a backslash \\";

will print
This is a backslash \

As far as why, what you have won't work, the only issue I see is that you don't have a + between the string literal and the finalString.

Also note that as usual your code won't work on a non-windows computer, or one where the Windows folder isn't on the C drive, or not called Windows.

You can show full screen images without having to use System.getRuntime().exec(...) though. E.g.


All Answers

Answers by Expert:

Ask Experts


Artemus Harper


I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.


I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Washington State University

MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2017 All rights reserved.

[an error occurred while processing this directive]