title: what is the work-around to "non-static variable cannot be referenced from a static context"?
body: <p>There's a particular idiom to putting a method, or perhaps anonymous inner class, somehow, into the main method of a driver class:</p>
  
  <pre><code>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
          }
           */
      }
  }
  </code></pre>
  
  <p>to prevent the below error:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>However, I can't find anything so far.  I see something similar in threading examples, but can't quite get the syntax.</p>
  
  <p>The following is largely what I want, but I don't think it's quite correct:</p>
  
  <pre><code>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();
      }
  }
  </code></pre>
  
  <p>What I would like is to put the instantiation of sf into...I'm not quite sure.  Maybe the above is correct and "ok"?</p>