users@glassfish.java.net

Launch application using windows file association

From: august2008 <b.menting_at_amnesty.nl>
Date: Mon, 25 Aug 2008 02:32:10 -0700 (PDT)

Hi,

I am looking for a way to launch a file from within a java program, the file
then opens the associated windows program. I have this working on a local
running glassfish, but cannot get it working on a server running glassfish.
I realize that there are limitations to this lauching, but the application I
am writing is only used within one building (local network) and the PCs on
which they are running have the same applications on them.

I have tried:
1)
Runtime rt=Runtime.getRuntime();
rt.exec("rundll32 url.dll,FileProtocolHandler \"" +
destinationFileName+"\"");

2)
String command[]={"cmd.exe "+destinationFileName};
ProcessBuilder pb = new ProcessBuilder(command);
Process p=pb.start();

3)
Desktop.getDesktop().open(new File(destinationFileName));

which all work locally, but none on the server. This morning I read a bit
about JNA (Java Native Access) and JDIC file type associations, but I fail
to understand if this is what I need, and if it will work.

I would really prefer a limited solution which is quick to implement (with
the above limitations - local network, no safety issues). If I do need
something else, a few lines of code are appreciated!

Thanks, Bert.

-- 
View this message in context: http://www.nabble.com/Launch-application-using-windows-file-association-tp19140580p19140580.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.