java调用浏览器打开链接代码

调用IE浏览器打开链接URL:
Runtime.getRuntime().exec("cmd /c start iexplore http://www.baidu.com/");

ProcessBuilder builder = new ProcessBuilder(
"c:\\Program Files\\Internet Explorer\\iexplore", "http://www.baidu.com");
builder.start();

>实际上就是调用CMD控制台来调用IE浏览器,所以这行代码也可以用来实现其他的CMD指令。

调用默认浏览器打开链接URL:
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.baidu.com/");

posted @ 2017-07-27 09:48  hasa.yu  阅读(930)  评论(0编辑  收藏  举报