Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   nonstatic method glitch? (http://www.velocityreviews.com/forums/t734940-nonstatic-method-glitch.html)

countnoobula 10-07-2010 03:31 PM

nonstatic method glitch?
 
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

dostcasper 10-19-2010 07:11 AM

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());
}
}
}
}


All times are GMT. The time now is 12:39 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.