• Post Reply Bookmark Topic Watch Topic
  • New Topic

Launching Windows image viewer from java app  RSS feed

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to be able to launch an image viewer from windows through my java app. I've got the code on how to launch the application, however, I can't seem to find or figure out how I can get the default image viewer that is set up for windows.

Our users don't have the same default image viewer (some user imaging, others use VuePro, etc.), so I can't just tell my app to run one certain application.

So, any ideas on how to do this?

Thanks in advance!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, I just typed this elsewhere maybe last night. Google for java exec and rundll32. The examples you find will all pass URL or HTML file arguments to launch Explorer, but rundll32 will launch the default application for any extension (assuming there is one). As a test, open a DOS prompt window and type the name of a file like a command:

c:\myFiles\myPicture.jpg

Some image viewer should pop up. rundll32 will do pretty much the same thing. Lemme know if that works for you. It can be a little unpredictable since you don't know what application might pop up.
 
Jonathan Night
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't know it was possible to run the default app with rundll32... I thought the only way to do it was via the java exec Runtime. Thanks for teaching me something new.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip! I did some messing around with this, and it is bringing up the default viewer for whatever pathname I put in. However, I have run across one problem, that I can't seem to figure out and was hoping you had a suggestion for me. I successfully pulled up images from my hard drive, and the server using the drive letter name. But when I put the server name or IP address in the path name instead of using the drive letter, it doesn't find it. I tried the server name in the path while in a DOS prompt, and it came up OK. It just doesn't work when I run it through my exec() in my program.

This is the string I am passing for the path:
\\\\gc1\\engimag\\testfile\\jj-4000.tif

Any ideas?

Thanks again!
[ June 09, 2004: Message edited by: Jennifer Sohl ]
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out my problem with using server name vs. drive letter (It was a String issue)...
Now, once the java app has launched the image viewer, what do I need to do to make sure that when the user closes the image viewer, the process gets shut down? Right now, they close the image viewer, but in task manager the executable for the image viewer still shows as a process.
What do I need to do after the viewer has been launched??

Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!