Open a file with its defualt associated application

is there any way to open any file with its defualt associated application from a java program ?Example:In Windows I have a file example.txt and, from a java program, I would like opening it by the defualt associated application Notepad.Thx
[274 byte] By [lambu76] at [2007-9-26 10:36:31]
# 1

This might be of use to whomever finds this in the future, as this is an old post, and I had trouble finding an answer to this online.

This link talks about several things, but I think you will find the part on opening files with there associated programs with little effort.

http://www-106.ibm.com/developerworks/library/os-ecgui3/

the class of interest is:

org.eclipse.swt.program.Program

java doc located here

ttp://download.eclipse.org/eclipse/downloads/documentation/2.0/html/plugins/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/program/Program.html#launch(java.lang.String)

Of course, this is a solution complements of the Eclipse IDE, so you will have to get the appropriate JAR.

Happy Coding,

Chad Olsen Isom

uvnet_programmer at 2007-7-1 23:02:09 > top of Java-index,Other Topics,Java Community Process (JCP) Program...
# 2

AFAIK, that's Windows specific. The version of Program.java that I have is very Windows-specific, with a large number of Registry accesses, use of Windows' ShellExecuteEx(), etc. etc.

For other platforms you're going to need to either write native code, use platform-specific bindings provided by the platform's vendor (e.g., Apple), try and issue shell commands and then parse the output, or use a third-party library.

tolstoy_dot_com at 2007-7-1 23:02:10 > top of Java-index,Other Topics,Java Community Process (JCP) Program...