title: Getting the Invocation Name Used in Java
body: <p>I'm trying to find a generic way to replicate this C functionality:</p>
  
  <pre><code>int main(int argc, char** argv){
      fprintf(2,"%s: error you did something wrong.\n", argv[0]);
      return 1;
  }
  </code></pre>
  
  <p>in java. So far the only way was to hardcode this into the app, which is ugly. I'd like to get something similar to:</p>
  
  <pre><code>someObj.getClass().getSimpleName();
  </code></pre>
  
  <p>inside my static main, without referring back to my own class.</p>
  
  <p>Is this even possible?</p>
  
  <h2>Edit</h2>
  
  <p>My searching for a good hour didn't turn this one up.</p>
  
  <p>Duplicated question, see <a href="https://stackoverflow.com/questions/41894/0-program-name-in-java-discover-main-class">$0 (Program Name) in Java? Discover main class?</a> for answer</p>