class MyException extends Exception { public MyException() { } public MyException(String s) { super(s); } } public class test_stacktrace { static void a() throws MyException { b(); } static void b() throws MyException { c(); } static void c() throws MyException { throw new MyException(); } public static void main(String argv[]) { try { a(); } catch(MyException e) { e.printStackTrace(); } } }