Ultimately what I want is something similar to the answer from this question:
Find where java class is loaded from
There's one twist. Unlike the examples, I don't know what class will contain the main method at compile time. But if I knew which class was called first, I could then locate where my application was executed from.
So my question is this: How do I discover what class contains the main method that was called to execute my java application?
EDIT (Clarification):
I want to have a library to know the "name" of the application I'm running. So if I type in java -cp ... MyMainClass and my main class happened to live in the folder /usr/something/myApp/lib/MyMainClass.jar then I could report back "myApp". This would be a fallback default option to infer my program's name.