Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke a browser via Java coding?

Tags:

java

browser

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?

like image 523
Sidharth Avatar asked Dec 09 '22 18:12

Sidharth


2 Answers

You can use the desktop API:

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

This would launch a browser

like image 73
oxbow_lakes Avatar answered Dec 12 '22 06:12

oxbow_lakes


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

like image 37
BalusC Avatar answered Dec 12 '22 06:12

BalusC