I have for example .pdf file (path to that file). How to open this file in default application (probably Acrobat Reader) from SWT application (for example on Button click) ?
I have for example .pdf file (path to that file). How to open this
Share
You should be able to use:
to open the file (using the default application or creator). From the javadoc:
Note that there are some peculiarities in
Program.launch()(or at least there were, though these may have been fixed in more recent versions of the runtime.) I don’t really remember the specifics of the bugs, but we do some checks to work around some issues:If you’re on a Unix platform, and you’re specifying an absolute path, there may be trouble opening that file. We prefix absolute paths with
/.– so that/tmp/foowould be translated to/./tmp/foo– although I don’t really remember the specifics of this bug any more than that.On Windows, if you’re trying to open a UNC path – for example
\\server\bar– you need to wrap the string in double-quotes. For example:Program.open("\"\\server\bar\"");