Java open internet browser

Reply

Join Date: Dec 2004
Posts: 4,181
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 481
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Java open internet browser

 
0
  #1
Feb 10th, 2006
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/"));
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Java open internet browser

 
0
  #2
Feb 10th, 2006
Are you putting that in a try-catch clause? If so, what does it look like?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,181
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 481
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Java open internet browser

 
0
  #3
Feb 10th, 2006
No I don't, just simple check for action event which is build on if statement

  1. else if(evt.getSource() == menuItemRules)
  2. {
  3. Desktop.browse(new URL( "http://www.google.co.uk/"));
  4. }
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Java open internet browser

 
0
  #4
Feb 10th, 2006
Anytime you mess with a URL you'll need to catch a malformedURLException and for the desktop thing,

  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. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,181
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 481
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Java open internet browser

 
0
  #5
Feb 10th, 2006
Can you translate this :cheesy:
  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...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC