0

I use the following code to display a gif image in Java by calling a runtime command, it opens the WindowsPhotoGallery, but doesn't display my image, instead it shows a bunch of other pictures on my PC, my question is : how to pass the gif image file name to it properly, so it will open with my image.

Now I'm passing it like this : C:\Program Files\Windows Photo Gallery\WindowsPhotoGallery "C:/abc.gif"

Which is incorrect, what's the right way to do it ?

String Command,Program,File_Path="C:/abc.gif";
Process process=null;

Program="C:\\Program Files\\Windows Photo Gallery\\WindowsPhotoGallery ";          
Command=Program+"\""+File_Path+"\"";

try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
Frank
  • 30,590
  • 58
  • 161
  • 244

2 Answers2

1

You can use Runtime.exec(String[] cmdArray) to pass a command and its arguments.

Valentin Rocher
  • 11,667
  • 45
  • 59
0

The problem is in the command line string.

for example : c:\document and settting\pic.gif = "\"c:\document and setting\pic.gif\""

ariso
  • 1,433
  • 6
  • 21
  • 35
  • I don't quite get it. My actual command look this this : C:/Program Files/Windows Photo Gallery/WindowsPhotoGallery C:/Dir_Stock_Data/ACC.gif I tried to put quotes around it different ways, the results are still the same. What did I do wrong ? – Frank May 25 '09 at 18:13