使用 Java 秋千发射 Google 地球
Launching Google Earth using Java swing
有人可以帮助我如何使用 Java swing 启动 Google 地球应用程序吗? (我的意思是点击 GUI 按钮它应该打开 Google 地球应用程序)
你可以试试这个
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();
}
有人可以帮助我如何使用 Java swing 启动 Google 地球应用程序吗? (我的意思是点击 GUI 按钮它应该打开 Google 地球应用程序)
你可以试试这个
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();
}