Re: how i will open (from Java Application) the MS word format /html documentsin repective Applications in Linux OS?



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

Steve W. Jackson wrote:

In article <1152713754.623401.136680@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Ayodhya" <apaikaray@xxxxxxxxx> wrote:

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 =
--
Steve W. Jackson
Montgomery, Alabama

.



Relevant Pages

  • Re: User Rights Assignment - not available - Resolved
    ... Thanks Steve for your effort to help me here. ... If none of that works I would try an upgrade/repair install ... it shows user rights and use the Resource Kit command line tool ... This operation may find that this database is corrupt ...
    (microsoft.public.windowsxp.security_admin)
  • Re: how i will open (from Java Application) the MS word format /html documentsin repective Applicati
    ... documentsin repective Applications in Linux OS? ... What I did in the Linux version of our product was require an external ... I create a URI object around it and use that. ... array by separating the CDE command line at the spaces, ...
    (comp.lang.java.programmer)
  • Re: MC Alternative? (File Managers)
    ... > graphical file manager. ... > you usually use a GUI. ... file manager and I use the command line but it would not be by 25%. ... and you are rabidly against gui interfaces, why do you want to limit ...
    (comp.os.linux.misc)
  • Re: MC Alternative? (File Managers)
    ... > graphical file manager. ... > you usually use a GUI. ... file manager and I use the command line but it would not be by 25%. ... and you are rabidly against gui interfaces, why do you want to limit ...
    (comp.unix.questions)
  • Re: Does anyone know exactly what the repair function does?
    ... is there a command line version that can be used inside a ... >I ran into a wierd problem on a tricky navy network, and in order to keep my ... >lan connection up, I am forced to monitor it constantly and press the ... Steve Winograd, MS-MVP ...
    (microsoft.public.windowsxp.network_web)