For example, one application that I'm working on stores PDF files into a database, then can pull them back out for display. I've got a call in there using Runtime.exec to do a "cmd /c start " plus the PDF filename. Works great for Windows. Would prefer to find a platform independent way (trying to avoid OS detection with alternate methods for various OS) to do this though as we also run the software on Solaris and Mac.
views:
31answers:
2
+1
A:
I'd be interested to see if there is a 'correct' answer for this. If I were to do this, I'd have a properties file mapping of OS to the command needed to run, and then resolve the OS at runtime.
Eg in a properties file:
windows=cmd /c start
mac=open #(I think)
linux=... etc
Noel M
2010-07-30 14:38:26
Not a bad idea, but something I would like to avoid.
Brian Knoblauch
2010-07-30 15:03:20
+3
A:
Look at Desktop which has a open method and that would be platform independent.
Launches the associated application to open the file.
willcodejavaforfood
2010-07-30 14:45:09
*Exactly* what I was looking for! I see there's a method to see if Desktop is supported... Are there platforms where Desktop is currently not supported?
Brian Knoblauch
2010-07-30 15:06:48
@Brian Knoblauch - Always worked for me, but probably a few platforms I've never used :)
willcodejavaforfood
2010-07-30 15:47:16
So far, I can confirm that it's supported on Windows and Solaris!
Brian Knoblauch
2010-08-03 18:56:19