invoke os default file handler

E

epicwinter

I work with a large application that we do a lot of reporting for by
producing pdfs using jasperreports. Additionally we are currently
adding a mini document manager that allows users to associated
documents with data (word, excel, whatever). Storing these documents
is easy but I am trying to figure out a cross-platform manner to view
them. I see a lot of threads of people trying to display pdfs without
much luck except by using exec on adobe.

The only method I can think of is to have a preferences file that
associates a file type with a executable .doc = msword.exe, .pdf =
acrobat.exe, etc. But I find this to be rather cumbersome, especially
when all operating systems seem to have default file handlers built in
already. When you click on a pdf on your linux , windows, or mac box
it automatically pops up the default application. So what I am
wondering is if there is a way to invoke this default handler from a
java application cause I sure don't want to rebuild the wheel???
 
S

Steve W. Jackson

:I work with a large application that we do a lot of reporting for by
:producing pdfs using jasperreports. Additionally we are currently
:adding a mini document manager that allows users to associated
:documents with data (word, excel, whatever). Storing these documents
:is easy but I am trying to figure out a cross-platform manner to view
:them. I see a lot of threads of people trying to display pdfs without
:much luck except by using exec on adobe.
:
:The only method I can think of is to have a preferences file that
:associates a file type with a executable .doc = msword.exe, .pdf =
:acrobat.exe, etc. But I find this to be rather cumbersome, especially
:when all operating systems seem to have default file handlers built in
:already. When you click on a pdf on your linux , windows, or mac box
:it automatically pops up the default application. So what I am
:wondering is if there is a way to invoke this default handler from a
:java application cause I sure don't want to rebuild the wheel???

Nope. Not automatically, that is. And you already hit on the reason
why, which is the fact that the mechanism used is platform-specific
while Java is platform-agnostic.

I don't know much about the proper mechanism to use in Windows for
opening an application with its associated app, but somebody will
doubtless chime in.

I know that it can be done in Mac OS X with the "open" command. Simply
use "open filename" and it will automatically use the user's configured
application to open the file.

In Linux, I'm also not conversant on how it's done, though I suspect it
may vary with different desktop environments.

= Steve =
 
E

epicwinter

thanks for the reply, that method would work pretty well for me. At
least that way I would only need one property to be set rather than
having to worry about every single type. Does anyone know the windows
and linux commands that do this?
 
L

Lee Fesperman

thanks for the reply, that method would work pretty well for me. At
least that way I would only need one property to be set rather than
having to worry about every single type. Does anyone know the windows
and linux commands that do this?

For Windows, take a look at the start command.
 
E

epicwinter

thanks the start command works perfect. I just need to figure out the
linux commands. I assume there are different ones for each desktop
manager as steve alluded to. Ideally if I could figure out the kde and
gnome command that would cover as much as I need to. Unfortunately I
have sifted through the groups and can't find this command. Any linux
gurus?
 
T

Thomas Weidenfeller

I work with a large application that we do a lot of reporting for by
producing pdfs using jasperreports. Additionally we are currently
adding a mini document manager that allows users to associated
documents with data (word, excel, whatever). Storing these documents
is easy but I am trying to figure out a cross-platform manner to view
them. I see a lot of threads of people trying to display pdfs without
much luck except by using exec on adobe.

The Java way would be to use JAF (Java Activation Framework). However,
this boils down to maintaining an own MIME type file, since Sun's
reference implementation of the API is rather limited.

[It just strikes me: Wouldn't it be a good opportunity for an
open-source software project: To implement JAF for the common Unix/Linux
desktops in some reasonable way?]

BTW: The magic spell for Motif/CDE would be

dtaction Open your-file.pdf

/Thomas
 
E

epicwinter

Yeah my whole thing is all this stuff is already built into the OS or
DesktopManager I just want to invoke the existing system. Otherwise
everytime someone uninstalls a piece of software and replaces it with a
new piece then you have to make these changes in your software. Your
suggestion for the opensource project is promising, although I am
trying to avoid getting os specific.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top