Java tutorial
//package com.java2s; public class Main { public static String getClassName() { try { String fullClassName = new Exception().getStackTrace()[1].getClassName(); return fullClassName.substring(fullClassName.lastIndexOf(".") + 1); } catch (Exception ex) { return "UnknownClass"; } } }