aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes opening browser from swing. is it possible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "opening browser from swing. is it possible" Watch "opening browser from swing. is it possible" New topic
Author

opening browser from swing. is it possible

vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
is it possible to open browser from the java stand alone application using swing or any other api? I am trying to make a button or hyperlink on my screen. on click of the button a browser should open with a url mentioned in the code. please help.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
Have you tried Runtime.getRuntime().exec()?

But don't go anywhere near that method until you have studied the ProcessBuilder class and (much more important) Michael Daconta's classic article When Runtime.exec() won't.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
JDK6 introduced the Desktop class to open the default application for any given file.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
BareBonesBrowserLaunch is a very good way to get this done in a cross-platform, non-Java-6-dependent way.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
That sounds a better idea.
vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
thank you very much Campbell, Ulf, and Rob. i will look into the ways you suggested me. and get back to you, if got struck.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: opening browser from swing. is it possible