Hi there! I currently have an app that a user can right click on a part number to view an image. Currently what I am doing, is creating the file path (I have a file in DB2 that ,depending on the type of part number, has the directory that the image would be located in), then appending the file name and file extension. I am using the "cmd /c" to open up the default viewer for the file extension (using Runtime class). Is there a better way to do this? I don't want to have to tell my program what the file extension is, as different images are in different formats. How can I detect the file extension and have the correct default viewer open for it?
Sorry if I've confused anyone. If you need any further details or clarification, please let me know. Thanks for any help you can give me!
Have you considered using Java to display the image?
There is no emoticon for what I am feeling!
Joined: Feb 28, 2001
No, I have not. Currently the users are expressing they need an image viewing solution that has an explorer on the side,as well as the ability to view all file formats (includes excel, ppt, word, pdf..), and the ability to view thumbnails. But I am intrigued... can I do all of that within java? Haven't really explored that side of the language yet.
Joined: Sep 16, 2005
By images I thought you meant images -- jpeg, png etc... Now you start mentioning Microsoft's different document formats, and you're getting into sticky areas that make me wonder why you're writing any part of this in Java...
Joined: Feb 28, 2001
Basically what I want, is viewing software, that is capable of viewing pretty much all image and text type documents. We currently have an application that does that (we want to keep it, so they only have one program that allows them to view all different file types with it) . That same application is set as the default viewer for all image type files (.pdf included) . Through the java app, users will only be trying to view image type documentsk by right clicking on a part number to view the drawing of it. I need to know, how do I launch my default viewer without having to specify the file extension. this is what I am running now:
... which launches the viewer fine. But say the next part number doesn't have a .tif extension, but a .pdf extension... I have to hardcode in the program the file extension so it will open. What I want to do is something like this:
and have it automatically detect what type of a file it is, and open the correct default viewer that windows is set to.
Sorry if I've confused you again... this is hard for me to explain! Thanks for the replies :-)
Check out the JDIC (Java Desktop Integration Components) project - especially the FileExplorer example and the org.jdesktop.jdic.filetypes package. This won't go as far as launching the associated application - you'd have to do that, much as you do now - but at least it would provide a framework for this type of thing.
You may also want to look into SWT - I know that it provides some ActiveX/OLE integration for Windows. [ June 19, 2006: Message edited by: Nathan Pruett ]
Write once, run anywhere, because there's nowhere to hide! - /. A.C.