There is a certain button to show the image . How can I click this button to open an image in the Windows image viewer window if the absolute image path is known?

    1 answer 1

    You can use java.awt.Desktop .

    import java.awt.Desktop; import java.io.File; public class Test2 { 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."); } } 

    Desktop.getDesktop().open() calls the default program for this type of file. You can also call the default browser to open a link or a standard email client, etc.