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([B]n[/B]ew 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[B]([/B]new URL( "http://www.google.co.uk/"));

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

else if(evt.getSource() == menuItemRules)
	{
            try
            {
		Desktop.browse(new URL( "http://www.google.co.uk/"));
            }
            catch(MalformedURLException mue)
            {
               //error message
            }
            catch(DesktopException de)
            {
               //error message
            }
	}

Can you translate this :cheesy:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jdesk
top/jdic/desktop/internal/impl/ServiceManagerStub
        at org.jdesktop.jdic.desktop.internal.ServiceManager.getService(Unknown
Source)
        at org.jdesktop.jdic.desktop.Desktop.browse(Unknown Source)
        at MainWindow.actionPerformed(Game.java:176)
        at java.awt.MenuItem.processActionEvent(MenuItem.java:597)
        at java.awt.MenuItem.processEvent(MenuItem.java:556)
        at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:298)
        at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:286)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:466)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Press any key to continue...
This article has been dead for over six months. Start a new discussion instead.