title: How would I get the name of the class that has an inherited main method?
body: <p>I have an Application class that is the base class for a ClientApplication. The Application has a main method that prints the name of the class that was defined to invoke the main method.</p>
  <pre><code>public abstract class Application {
    // Using this class as the entry point would output &quot;Application&quot;
    public static void main ( String... args ) {
      // Print the name of the class that is calling the main method
    }
  }
  
  public class ClientApplication extends Application {
    // Using this class as the entry point would output &quot;ClientApplication&quot;
    // main is inherited and can be invoked via the ClientApplication class.
  }
  </code></pre>
  <p>I have tried to use an instantiated Object to get the name of the class like so:</p>
  <pre><code>public abstract class Application {
    public static void main( String... args ) {
      System.out.println( new Object() {}.getClass().getEnclosingClass().getSimpleName() );
    }
  }
  </code></pre>
  <p>But that prints out &quot;Application&quot; no matter which class is defined as the class that contains the main method.</p>