Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2005

Tip: Looking for answers? Try searching our database.

Linux: open file with proper app

Thread view: 
Steve W. Jackson - 09 Mar 2005 21:52 GMT
I'm probably going to have need soon of a way to open user-selected
files with an appropriate app.  In Windows and Mac OS X, I've long ago
worked out how to do this.  But the problem is different in Linux, in
large part because I'm not familiar with the workings of various window
managers (KDE, Gnome, etc.).

So can anyone suggest what might be a good approach, I'm guessing with
the Runtime.exec methods, to get this done?

All ideas appreciated.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

Thomas Weidenfeller - 10 Mar 2005 09:24 GMT
> I'm probably going to have need soon of a way to open user-selected
> files with an appropriate app.  In Windows and Mac OS X, I've long ago
> worked out how to do this.  But the problem is different in Linux, in
> large part because I'm not familiar with the workings of various window
> managers (KDE, Gnome, etc.).

Every desktop has its own way of doing things, as you suspected in
Message-ID: <stevewjackson-9C9728.15445625012005@individual.net> a month
ago :-)

> So can anyone suggest what might be a good approach, I'm guessing with
> the Runtime.exec methods, to get this done?

KDE: kfmclient exec <url>         # <url> can be a "file:" url, too

CDE: dtaction Open <file>         # open file - if an association exists
     dtaction WebBrowser <url>    # Open <url> in web browser

CDE - Solaris specific:

     dtaction SDtWebClient  <url> # open url in web browser
     dtaction Open <file>.url     # extract url from
                                 # contents of the file <file>.url
                                 # and open url
     dtaction Open <file>.mailto  # extract mailto url
                # from contents of the file
                                 # <file>.mailto and open mail editor

GNOME: No idea, probably via nautilus

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Steve W. Jackson - 10 Mar 2005 17:12 GMT
> > I'm probably going to have need soon of a way to open user-selected
> > files with an appropriate app.  In Windows and Mac OS X, I've long ago
[quoted text clipped - 27 lines]
>
> /Thomas

I recall that reply, now that you point it out.  It predates my current
need a bit but is also a little different.  The OP there appeared to be
looking for a way to associate apps with extensions, and I'm certainly
not going to do anything like that.

I've already worked out the simplest possible mechanisms in Win2K and
beyond (since our app no longer supports anything earlier) and Mac OS X,
to simply invoke a "file:" URL and let the system pass it on to the
associated application.

Based on your info above, and a quick test showing that the kfmclient
command you've provided works great on my Linux box, I think I need to
look at whether I can maybe let a user specify the method of doing it in
Linux.  That is, perhaps a properties file where the user makes an entry
providing the command line needed in their particular window manager,
which I can then read, parse, and hand off to Runtime.exec to get the
job done.

Thanks for the response -- it's helped tremendously.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

Thomas Weidenfeller - 11 Mar 2005 08:08 GMT
> I recall that reply, now that you point it out.  It predates my current
> need a bit but is also a little different.  The OP there appeared to be
> looking for a way to associate apps with extensions,

Associating applications with extensions and/or magic numbers is the
first step in getting this to work. If you are lucky there is already
such an association. If not, one has to be created.

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Steve W. Jackson - 11 Mar 2005 17:56 GMT
> > I recall that reply, now that you point it out.  It predates my current
> > need a bit but is also a little different.  The OP there appeared to be
[quoted text clipped - 5 lines]
>
> /Thomas

I agree, but it's external to my application and is instead a part of
the user's desktop environment.  So I'm basically going to assume that
the user already has it set up as desired.

The info provided in an earlier reply pointed me toward resources that
show how to hand off a request to an appropriate application, so that
the defined association can be used to launch an appropriate program.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.