我正在编写一个java应用程序,我想在用户的默认Internet浏览器中打开我的程序的链接.我试着像这样使用类桌面:
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
URI uri = new URI(url); // url is a string containing the URL
desktop.browse(uri);
}
catch (URISyntaxException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但首先如果返回false.我的操作系统是Ubuntu的最新版本.有人知道如何在java中支持该桌面吗?