【问题标题】:Launching Google Earth using Java swing使用 Java swing 启动 Google 地球
【发布时间】:2016-03-15 11:24:24
【问题描述】:

谁能帮助我如何使用 Java swing 启动 Google 地球应用程序? (我的意思是点击 GUI 按钮,它应该会打开 Google 地球应用程序)

【问题讨论】:

标签: java swing google-earth


【解决方案1】:

你可以试试这个

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

或者通过其他方式

  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();
  }

【讨论】:

    猜你喜欢
    • 2010-12-25
    • 1970-01-01
    • 2012-04-05
    • 2012-08-28
    • 1970-01-01
    • 2019-05-21
    • 1970-01-01
    • 1970-01-01
    • 2022-10-20
    相关资源
    最近更新 更多