tags:

views:

83

answers:

2

What I need is to instruct OS to open the file with the default program used for that file type. Exactly as if, i.e., that file was double-clicked by user under Windows.

The purpose is, i.e., "your PDF file was generated. Click here to open it".

In platform-independent way, if possible...

I dont know exact terms for what I want, so if someone could update tags, I'd most appreciate that ;)

+6  A: 

You need the Desktop class, and the open() method in particular.

Launches the associated application to open the file. If the specified file is a directory, the file manager of the current platform is launched to open it.

Brian Agnew
+3  A: 

Since Java 6, we have Desktop.open() for exactly that purpose.

Michael Borgwardt
what about 1.5 or before.. any reference ?
Nrj
@Nrj: there was no platform-independant way to do it before Java 6. You could use Runtime.exec() to call platform-specific mechanisms via the shell, such as Windows' *start* command.
Michael Borgwardt