How to invoke a browser via Java coding?

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

I want to invoke a browser (e.g. Internet Explorer/Firefox/Google Chrome/Opera) via a Java interface. Also I need to pass some web links to this Java process. How to achieve this?

回答1:

You can use the desktop API:

java.awt.Desktop.getDesktop().browse(new URI("http://stackoverflow.com")); 

This would launch a browser



回答2:

You can do that with Desktop#browse(). It would however only launch the system default configured browser.



回答3:

See Using the Desktop API in Java SE 6 "Opening the Browser"



回答4:

You can run the browser executable as a separate process.

Click this link on how to execute an external process in Java.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!