Java examples for Native OS:Browser
open Web page via system default browser
//package com.java2s; import java.awt.*; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; public class Main { public static void openWebpage(URI uri) { Desktop desktop = Desktop.isDesktopSupported() ? Desktop .getDesktop() : null;// w ww.jav a 2 s. co m if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try { desktop.browse(uri); } catch (Exception e) { e.printStackTrace(); } } } public static void openWebpage(URL url) { try { openWebpage(url.toURI()); } catch (URISyntaxException e) { e.printStackTrace(); } } }