爪哇 - 仅在Chrome浏览器中打开URL [英] java - open url in chrome browser only
本文介绍了爪哇 - 仅在Chrome浏览器中打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网址,我试图打开JavaFX中的Web视图该网址,但内容不符合Web视图兼容。这是唯一的Chrome和Firefox兼容。所以,我想打开Chrome浏览器的网址,而不是只在网页视图中打开它。这可能吗?(我不希望在默认浏览器打开它。)
我试过低于code,但我们得到了为无法运行程序铬错误:错误= 2,没有这样的文件或目录。
调用Runtime.getRuntime()的exec(新的String [] {铬,http://goo.gl/EsomR0});
感谢,
解决方案
调用Runtime.getRuntime()。EXEC(新的String [] {CMD,/ C,启动铬http://goo.gl/EsomR0});
这为我工作。
-
编辑:
仅在Windows工作
I have an url, I am trying to open that url in web view of JavaFX but the content was not compatible with web view. It's only compatible to the chrome and firefox. So I would like to open that Url in chrome browser only instead of opening it in web view. is it possible?(I don't want to open it in default browser.)
I tried the below code but we got the error as "Cannot run program "chrome": error=2, No such file or directory".
Runtime.getRuntime().exec(new String[] { "Chrome", "http://goo.gl/EsomR0" });
thanks,
解决方案
Runtime.getRuntime().exec(new String[]{"cmd", "/c","start chrome http://goo.gl/EsomR0"});
This worked for me.
-- Edit: Only worked on Windows
这篇关于爪哇 - 仅在Chrome浏览器中打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文