I know that all of these answers basically answered the question, but here is the code for a method that gracefully fails.
Please note that the line may be the location of the html file
public static void openInBrowser(String url) { try { URI uri = new URL(url).toURI(); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { desktop.browse(uri); } else { throw new Exception("Desktop not supported, cannout open browser automatically"); } } catch (Exception e) { e.printStackTrace();
Troyseph Sep 07 '14 at 18:35 2014-09-07 18:35
source share