1. 程式人生 > >java調用瀏覽器打開鏈接代碼

java調用瀏覽器打開鏈接代碼

program protoc xpl .com ces time ava dll star

調用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/");

java調用瀏覽器打開鏈接代碼