how i will open (from Java Application) the MS word format /html documentsin repective Applications

A

Ayodhya

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)
 
S

Steve W. Jackson

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 =
 
A

Ayodhya

Thanx Steve for the nice explanation.i'll use this concept in my
application.But i could nt understand where the "file manager" type
application is used.i am attaching the code snippet for windows..

void openDocument(String filename)
{
String path = (String) documentInfo_.get(filename);//u get the URL
from here
String os = System.getProperty("os.name");
String command="";

if(os.startsWith("Windows"))
command = "rundll32 SHELL32.DLL,ShellExec_RunDLL";
else if(os.startsWith("LInux"))
;//TODO

try
{
//path is kept within double quotes.
command += " \"" + path + "\"";
Process process = Runtime.getRuntime().exec(command);
}
catch (Exception e)
{
e.printStackTrace();
}
}

Thank you
Ayodhya
 
A

Ayodhya

HI Steve,

I ahve implementaed the command u suggested but the linux os could not
recognise the "dtaction" command.

Yeah i have used the "kfmclient exec" which opens the word/html
document in KDE.but i need the documents should open in respective
applications(e.g .doc file should open in Openoffice, which comes by
default in linux").

Please suggest wht to do.

Thanks for ur suggestion.
Ayodhya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top