Ayodhya said:
how i will open (from Java Application) the MS word format /html
documentsin repective Applications in Linux OS?
(e.g. *.doc with Microsoft Word and html in IExplorer)
I asked for some info in these groups a long while back to help me do
exactly that. Unfortunately, I didn't learn nearly as much as I would
have liked. But I learned enough to get the basics figured out.
The specific method depends on the presence of a "file manager" type
application for the user which has been used to designate appropriate
applications for selected file extensions.
What I did in the Linux version of our product was require an external
properties file. I required the presence of two properties, which I
named "file.view" and "url.view", so that I could handle either a file
or a user-provided URL, respectively. The value of each property must
contain the command line to which I will append a URI. If a file is to
be opened, I use the File object's toURI method. If a user-provided URL
is to be opened, I create a URI object around it and use that.
In a CDE setting (popular on Solaris but sometimes used in Linux), the
"file.view" property contains "dtaction Open". I constructed a string
array by separating the CDE command line at the spaces, and the file URI
goes into the third spot. Then I just use a Runtime.exec call to launch
it.
In CDE, the command "dtaction WebBrowser" is used with HTTP URLs, and
the same thing is done.
I commonly use KDE on our Linux box. There, I've found that the command
"kfmclient exec" works for both of the above properties.
And in a Gnome environment, if the "nautilus" program is used for file
management, the command line for both of those properties only needs
"nautilus" and then the URI.
In some respects, this puts the burden on Linux users of determining
what the proper command is for their environment. But with the variety
of desktops and file managers, I think it's hard to do much else.
I don't use an external properties file for Windows or Mac OS X since
both of those have predetermined mechanisms for handing off URIs to
specified applications. For Windows, I kept it very simple and built a
string array around "cmd /c start URI". Our app isn't available on any
Windows earlier than 2000, so that command is great; on Win98 it won't
work. Our app isn't yet supported on Mac OS X, but I'm planning ahead.
For that platform, the command line is "open URI", which hands off the
URI to either a local application (for a file) or to the user's
designated web browser, FTP app, etc.
HTH.
= Steve =