java non-static variable in static context
<p>I have the following code : </p>

<pre><code>public class My_program {

    class dbConnect {
       public dbConnect();
       public void connect_to_db(String connect_string) {
          Class.forName(...);
          ...
       }
    }

    public static void main(String[] args) {
       String connect_string = "jdbc...";
       dbConnect db = new dbConnect();
       db.connect_to_db(connect_string)
    }
}
</code></pre>

<p>When I try to compile it, the following error occurs :</p>

<pre><code>error: non-static variable this cannot be referenced from a static context
</code></pre>

<p>so I tried to make the <code>dbConnect</code> static like this : <code>static class dbConnect</code> and it's working ok but java is generating an extra <code>.class</code> file : <code>My_program$dbConnect.class</code> that <strong>I do not want</strong>. </p>

<p>So how can I have a single <code>.class</code> file and get the code to work .</p>
