tags:

views:

110

answers:

4

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?

+4  A: 

You can use the desktop API:

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

This would launch a browser

oxbow_lakes
can i use this API to invoke multiple weblinks? ..thats is i have given - http://stackoverflow.com - i want to invoke with 5 links initially
Sidharth
I guess call the method 5 times?
oxbow_lakes
but it will open a separate browser for each call ... but i want to open in the same browser with tabs . how to achieve this?
Sidharth
FYI, for those using Java 5 or earlier: http://www.centerkey.com/java/browser/
Matt Solnit
+2  A: 

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

BalusC
A: 

You can run the browser executable as a separate process.

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

Pablo Santa Cruz
+1  A: 

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

Pierre