jQuery in Action, 3rd edition
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
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: 44028
    
  33
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: 2373
    
    8
JDK6 introduced the Desktop class to open the default application for any given file.
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
BareBonesBrowserLaunch is a very good way to get this done in a cross-platform, non-Java-6-dependent way.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44028
    
  33
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: opening browser from swing. is it possible
 
It's not a secret anymore!