I want to determine the class name where my application started, the one with the main() method, at runtime, but I\'m in another thread and my stacktrace doesn\'t go all the
See the comments on link given by Tom Hawtin. A solution is these days is (Oracle JVM only):
public static String getMainClassAndArgs() {
return System.getProperty("sun.java.command"); // like "org.x.y.Main arg1 arg2"
}
Tested only with Oracle Java 7. More information about special cases: http://bugs.java.com/view_bug.do?bug_id=4827318