The Desktop.getDestop().open(File) launches the associated aplication to open the file.
The Desktop class is available since Java 1.6 - http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html
How to do the same using the 1.4 Java version?
The Desktop.getDestop().open(File) launches the associated aplication to open the file.
The Desktop class is available since Java 1.6 - http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html
How to do the same using the 1.4 Java version?
you can use the following to open files with the default application:
/* build up command and launch */
String command = "";
String file = "FILE IN HERE";
if (isLinux()) {
command = "xdg-open " + file;
} else if (isWindows()) {
command = "cmd /C start " + file;
} else
return;
try {
Runtime.getRuntime().exec(command);
} catch (Exception ex) {
ex.printStackTrace();
}
available since 1.0: Runtime.
OS class to determine the host operating system at runtime.cmd /C start as you suggested, I don't get any information on whether it successfully started. Do you know of any workaround for this?cmd /C start command, I lose the handle to the process because it starts a command window which in turn start my target process and exits.Runtime.exec()
More details can be found at: http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html