/** * Launches the default browser to display a URL. * * @param url the URL to be displayed * @since 4.1 */ static void openURL(String url) { try { openURL(new URL(url)); } catch (MalformedURLException ex) { Tools.showError(ex); } }
/** * Launches the default browser to display a URL. * * @param url the URL to be displayed * @since 4.1 */ static void openURL(URL url) { if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { try { Desktop.getDesktop().browse(url.toURI()); } catch (Exception ex) { Tools.showError(ex); } } else if(SystemUtils.IS_OS_LINUX) { //handle the case where Desktop.browse() is not supported, e.g. kubuntu //without libgnome try { Runtime.getRuntime().exec(new String[] { "xdg-open", url.toString() }); } catch (Exception ex) { Tools.showError(ex); } } }