Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

load web page from standalone app?

 
Marc Santiago
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a standalone application, I want to start up a browser session (if one isn't available already) and load a web page (my website's FAQ). How do I do this?
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime.getRuntime().exec()
Or if you prefer a pure java solution, you can display HTML in
Swing Components.
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, this is a good example of how to display HTML using Swing.
 
Vinod Chandana
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
one way to do it is to use Runtime and give an exec call to
"iexplore YourURL"

Hope this helps.
Vinod.
 
Marc Santiago
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm kind of looking for a non-platform-specific implementation, so starting an instance of IE wouldn't always work. What I was really looking for was a way to say to the OS, 'I want to display this web page - go fire up whatever you use for a browser and load this URL'.
I'm curious about the Swing implementation. Does this embed a web browser into your standalone app, or does it somehow invoke the OS's 'default' web browser? If it uses its own embedded browser, would it understand Javascript? I couldn't tell from just reading the page.
Thanks everyone for all your help!
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marc S.:
I'm curious about the Swing implementation. Does this embed a web browser into your standalone app, or does it somehow invoke the OS's 'default' web browser? If it uses its own embedded browser, would it understand Javascript?

JeditorPane and JTextPane are Java GUI controls which can be used to display HTML (and other formatted text). I do not believe it understands Javascript. There is no cross-platform way to invoke the OS's 'default' web browser.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A lot of work was put in to Browser Opener - com.Ostermiller.util Java Utilities. This is as platform independant as you can get. There is no java class ( besides the Runtime class, which is OS specific ) which can do this.
Jamie
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On another note:
Marc S.:
Welcome to the Ranch! We hope you’ll enjoy pounding back pints of java help on a regular basis. However, we do have one tiny rule around these parts. Please change your display name to one that satisfies our tiny rule, the naming policy( The skinny of the rule: just use a real firstname, followed by a space and a real lastname ). That's all! Thanks again and we hope to see you ordering up pints of java help and pitchers of java answers on a regular basis!
Jamie
 
Marc Santiago
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Ostermiller Browser looks like exactly what I'm looking for. Thanks!
Oh, and I fixed my name. Sorry about that - I'm just a little paranoid about my private info.
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BrowserLauncher. I have used it for years:
http://browserlauncher.sourceforge.net/
brian
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the Other APIs forum...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic