nonstatic method glitch?

Discussion in 'Software' started by countnoobula, Oct 7, 2010.

  1. countnoobula

    countnoobula

    Joined:
    Oct 7, 2010
    Messages:
    1
    firstly here is my code

    Code:
    package ProgramUtils;
    
    import java.awt.Desktop;
    import java.net.URI;
    
    public class BrowserLaunch {
        public void openUrl(URI uri) {
            if( java.awt.Desktop.isDesktopSupported() ) {
                try {
                    Desktop.browse(uri);
                } catch ( Exception e ) {
                    System.out.println(e.toString());
                }
            }
       }
    }
    but no matter how hard i try, i always get the same error from teh file (PS: I am using netbeans so it hunts it down to individual files)
    Here is the particular error if its any help
    Code:
    non-static method browse(java.net.URI) cannot be referenced from a static context
    Thanks
     
    countnoobula, Oct 7, 2010
    #1
    1. Advertising

  2. countnoobula

    dostcasper

    Joined:
    Sep 19, 2008
    Messages:
    1
    TRy using below code

    package ProgramUtils;

    import java.awt.Desktop;
    import java.net.URI;

    public class BrowserLaunch {
    public void openUrl(URI uri) {
    if( java.awt.Desktop.isDesktopSupported() ) {
    try {
    Desktop deskTop = new Desktop();
    deskTop.browse(uri);
    } catch ( Exception e ) {
    System.out.println(e.toString());
    }
    }
    }
    }
     
    dostcasper, Oct 19, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim
    Replies:
    1
    Views:
    494
  2. History Fan

    Strange scrolling glitch with Firefox

    History Fan, Feb 21, 2006, in forum: Firefox
    Replies:
    7
    Views:
    1,156
  3. JIM

    Network glitch

    JIM, Jan 29, 2004, in forum: Computer Support
    Replies:
    6
    Views:
    606
  4. br1ght

    IE 6.0 Links/Toolbar glitch

    br1ght, Feb 20, 2004, in forum: Computer Support
    Replies:
    8
    Views:
    579
    °Mike°
    Feb 24, 2004
  5. Robert11
    Replies:
    6
    Views:
    1,421
    nota chance
    Aug 2, 2004
Loading...

Share This Page