【发布时间】:2016-03-15 11:24:24
【问题描述】:
谁能帮助我如何使用 Java swing 启动 Google 地球应用程序? (我的意思是点击 GUI 按钮,它应该会打开 Google 地球应用程序)
【问题讨论】:
-
@Tirma 这不是有效的副本,请比较答案。
标签: java swing google-earth
谁能帮助我如何使用 Java swing 启动 Google 地球应用程序? (我的意思是点击 GUI 按钮,它应该会打开 Google 地球应用程序)
【问题讨论】:
标签: java swing google-earth
你可以试试这个
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();
}
【讨论】: