944,088 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 13840
  • Java RSS
Feb 10th, 2006
0

Java open internet browser

Expand Post »
Can somebody please provide my with usefull info how to open internet browser from java program? The way how this should work, work cross platform & open default browser don't force certain browser

I tried to use info from this page but couldn't get it work. Together with tutor we downloaded requered libraries. But when implemented compiler give us following errors, red parts mark erorr place

C:\CW1 - Game\Game.java:174: 
unreported exception java.net.MalformedURLException; 
must be caught or declared to be thrown 
Desktop.browse(new URL  ( "http://www.google.co.uk/"));
                                       
C:\CW1 - Game\Game.java:174: 
unreported exception org.jdesktop.jdic.desktop.DesktopException; 
must be caught or declared to be thrown 
Desktop.browse(new URL( "http://www.google.co.uk/"));
Similar Threads
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Feb 10th, 2006
0

Re: Java open internet browser

Are you putting that in a try-catch clause? If so, what does it look like?
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Feb 10th, 2006
0

Re: Java open internet browser

No I don't, just simple check for action event which is build on if statement

Java Syntax (Toggle Plain Text)
  1. else if(evt.getSource() == menuItemRules)
  2. {
  3. Desktop.browse(new URL( "http://www.google.co.uk/"));
  4. }
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Feb 10th, 2006
0

Re: Java open internet browser

Anytime you mess with a URL you'll need to catch a malformedURLException and for the desktop thing,

Java Syntax (Toggle Plain Text)
  1. else if(evt.getSource() == menuItemRules)
  2. {
  3. try
  4. {
  5. Desktop.browse(new URL( "http://www.google.co.uk/"));
  6. }
  7. catch(MalformedURLException mue)
  8. {
  9. //error message
  10. }
  11. catch(DesktopException de)
  12. {
  13. //error message
  14. }
  15. }
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Feb 10th, 2006
0

Re: Java open internet browser

Can you translate this :cheesy:
Java Syntax (Toggle Plain Text)
  1. Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jdesk
  2. top/jdic/desktop/internal/impl/ServiceManagerStub
  3. at org.jdesktop.jdic.desktop.internal.ServiceManager.getService(Unknown
  4. Source)
  5. at org.jdesktop.jdic.desktop.Desktop.browse(Unknown Source)
  6. at MainWindow.actionPerformed(Game.java:176)
  7. at java.awt.MenuItem.processActionEvent(MenuItem.java:597)
  8. at java.awt.MenuItem.processEvent(MenuItem.java:556)
  9. at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:298)
  10. at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:286)
  11. at java.awt.EventQueue.dispatchEvent(EventQueue.java:466)
  12. at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
  13. read.java:242)
  14. at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
  15. ad.java:163)
  16. at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
  17.  
  18. at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
  19.  
  20. at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
  21. Press any key to continue...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: java help for newbie
Next Thread in Java Forum Timeline: Homework HELP!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC