Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private final static char NOT_A_DOT = '$'; private final static char DOT = '.'; private static String classNameForTarget(Object target) { String packageName = target.getClass().getPackage().getName(); String className = target.getClass().getName(); className = className.substring(packageName.length() + 1).replace(DOT, NOT_A_DOT); return packageName + DOT + className; } }