There's a particular idiom to putting a method, or perhaps anonymous inner class, somehow, into the main method of a driver class:
package net.bounceme.dur.misc;
import net.bounceme.dur.misc.Foo;
public class StaticRef {
    Foo f = Foo.INSTANCE;
    public static void main(String[] args) throws Exception {
        f.connect();  //move this to inside "run"
        /*
        public void run(){
           StaticRef sf = new StaticRef();
           //do stuff here
        }
         */
    }
}
to prevent the below error:
init:
Deleting: /home/thufir/NetBeansProjects/nntp/build/built-jar.properties
deps-jar:
Updating property file: /home/thufir/NetBeansProjects/nntp/build/built-jar.properties
Compiling 1 source file to /home/thufir/NetBeansProjects/nntp/build/classes
/home/thufir/NetBeansProjects/nntp/src/net/bounceme/dur/misc/StaticRef.java:11: non-static variable f cannot be referenced from a static context
        f.connect();  //move this to inside "run"
1 error
/home/thufir/NetBeansProjects/nntp/nbproject/build-impl.xml:626: The following error occurred while executing this line:
/home/thufir/NetBeansProjects/nntp/nbproject/build-impl.xml:245: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
However, I can't find anything so far. I see something similar in threading examples, but can't quite get the syntax.
The following is largely what I want, but I don't think it's quite correct:
package net.bounceme.dur.misc;
public class StaticRef {
    Foo f = Foo.INSTANCE;
    public static void main(String[] args) throws Exception {
        StaticRef sf = new StaticRef();
        sf.f.connect();
    }
}
What I would like is to put the instantiation of sf into...I'm not quite sure. Maybe the above is correct and "ok"?
 
     
     
     
    