jcs79 said:
fabienne hadek said:
yep
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(new String[] { "/bin/sh", "-c",
"./processfile.sh " + parameter}); // or whatever you want to do....
int exitVal = proc.waitFor();
out.println("Process exitValue: " + exitVal);
fabienne
This is a start, but I dont want to run a specific program, I want to
run whatever a default program is given a specific file type, e.g. if
I use a filechooser to select an mp3, java sends the command to
windows to run whatever application the user has set up to play mp3
files.
Okay, basically to do this you have to look into the windows registry to
figure out what the default application is. There are some open source
code out there that allows you to access the registry, but I don't
remember what they are right now. Just google it and you should find
something. Anyway, once you get the code to let you access the registry
you follow these basic steps:
1. Get the extension of the file.
2. Look in the registry for the default program for that extension.
The basic location in WinXP for that is "HKEY_CLASSES_ROOT\extension".
3. Take the resulting program string (PROGRAM_STRING) and then look for
the open command for that program. The basic location for that is
"HKEY_CLASSES_ROOT\PROGRAM_STRING\shell\open\command".
4. Use that as the first argument in the exec command as listed above.
Yes, this may seem like a pain, but it does work. I know this for a
fact as I've used it in the past. Hope that helps.
Matthew