java后台打开浏览器代码

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class aa{
    public static void main(String[] args) throws IOException, URISyntaxException {  
        String webSite = "http://www.baidu.com";
        OpenBroswer(webSite);
    }  
      
    public static void OpenBroswer(String webSite) throws URISyntaxException,  
            IOException {
        Desktop desktop = Desktop.getDesktop();  
        if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {  
            URI uri = new URI(webSite);  
            desktop.browse(uri);  
        }  
    }  
}

  

posted @ 2018-01-30 10:05  上海-chp-java  阅读(335)  评论(0编辑  收藏  举报