• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening a web page with Java problems(BrowserLauncher problems)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently trying to open a web page from an application. I have experience with I/O stream connections to web pages but not opening up the web page. BrowserLauncher was suggested to me, so I downloaded the BrowserLauncher class. I then tried to use test code to see if it would work. The BrowserLauncher class compiled, but my test class did not (this test class basically instanciated BrowserLauncher and called its openURL method to open a web page). When I tried to compile the test class, the Java compiler threw an exception that read "BrowserLauncher()
has private access in BrowserLauncher BrowserLauncher bl = new BrowserLauncher()." I was wondering if anyone had any ideas as why BrowserLauncher wasn't working or any other ideas on how to open up web pages in an application. Thanks.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I Googled the right BrowserLauncher, it looks like all methods are static so you don't need to create an instance. Skip the "new BrowserLauncher()" line and just start calling methods on the class, e.g. BrowserLauncher.doThis()

For Windows only (!) I like to use the RunDLL32 approach. Exec something like

rundll32 url.dll,FileProtocolHandler http://www.JavaRanch.com

The "FileProtocolHandler" is exactly like clicking a file in Explorer or entering a filename as a command in a command prompt. It will launch the default browser even if it is some weird thing you've never heard of. Try that line in a command window to see it go.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic