I want to open a file (say, a text document) from a Java application using the appropriate program installed on my computer (in this example, using MS Word or Open Office Writer).
The catch is that I want to wait until this subprocess completes, which can be done using the waitFor () method in the Process class.
String executable = findAssociatedApplicationPath(); //for example, returns "C:\\Program Files\\Microsoft Office\\Office12\\msword.exe" Process p = Runtime.getRuntime().exec(executable + " " + filepath); p.waitFor();
Can someone tell me how to write the findAssociatedApplicationPath () method so that it returns the correct executable? Or is there another way to do this?
java process associations runtime execute
Zurb
source share