0

Can someone please help me how to launch Google Earth application using Java swing? (I mean on click of the GUI button it should open the Google Earth application)

perror
  • 7,071
  • 16
  • 58
  • 85
user3438583
  • 155
  • 1
  • 2
  • 8

1 Answers1

0

You could try this

   if (Desktop.isDesktopSupported()) {
try {
    File myFile = new File("/path/to/file.exe");
    Desktop.getDesktop().open(myFile);
} catch (IOException ex) {
    // no application registered for PDFs
}
}

Or by Another Way

  try{

    if ((new File("c:\\your_file.exe")).exists()) {

        Process p = Runtime
           .getRuntime()
           .exec("rundll32 url.dll,FileProtocolHandler c:\\your_file.exe");
        p.waitFor();

    } else {

        System.out.println("File does not exist");

    }

  } catch (Exception ex) {
    ex.printStackTrace();
  }
manikant gautam
  • 3,521
  • 1
  • 17
  • 27