方法一,使用默认浏览器打开
Desktop d = Desktop.getDesktop();
URI address = null;
try {
address = new URI("https://www.baidu.com/");
} catch (URISyntaxException e) {
e.printStackTrace();
}
try {
d.browse(address);
} catch (IOException e) {
e.printStackTrace();
}
方法二 使用指定浏览器打开
FindContentEplus findContentEplus=new FindContentEplus(webview);
String path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
String target = "https://xxx;
List<String> cmd = new ArrayList<String>();
cmd.add(path);
// cmd.add("--start-maximized");// 窗口启动最大化
// cmd.add("--incognito");// 隐身模式打开
// cmd.add("--user-data-dir=D:/test");
cmd.add(target);
ProcessBuilder process = new ProcessBuilder(cmd);
try {
process.start();
} catch (IOException e) {
e.printStackTrace();
}