开发者

Platform independent way to fire off external applications/helpers by file type?

开发者 https://www.devze.com 2023-01-09 08:39 出处:网络
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

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 file开发者_开发百科name. 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.


Look at Desktop which has a open method and that would be platform independent.

Launches the associated application to open the file.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消