Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

opening browser from swing. is it possible

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2608
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDK6 introduced the Desktop class to open the default application for any given file.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BareBonesBrowserLaunch is a very good way to get this done in a cross-platform, non-Java-6-dependent way.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds a better idea.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic