• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Opening a file

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you considered using Java to display the image?
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :-)
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
put the selected file into a variable and use that

String fileName = [set from right-click on part number];
"cmd \c "+fileName
note the 'space' after \c
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Evildoers! Eat my justice! And this tiny ad's justice too!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic