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.
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:
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.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
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
Thanks again! [ June 09, 2004: Message edited by: Jennifer Sohl ]
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??