public class Main {
public static void main(String[] args) throws Exception {
String fileName = "c:\\temp\\test.bmp";
String[] commands = { "cmd.exe", "/c", "start", "\"DummyTitle\"",
"\"" + fileName + "\"" };
Process p = Runtime.getRuntime().exec(commands);
p.waitFor();
System.out.println("Done.");
}
}
Or, use the Desktop
class.
import java.awt.Desktop;
import java.io.File;
/*from w w w . j a v a 2 s . com*/
public class Main {
public static void main(String[] args) throws Exception {
File f = new File("c:\\temp\\test.bmp");
Desktop dt = Desktop.getDesktop();
dt.open(f);
System.out.println("Done.");
}
}