Here you can find the source of getClassFilePath(Class clazz)
public static String getClassFilePath(Class clazz)
//package com.java2s; import java.io.File; import java.net.URL; public class Main { public static String getClassFilePath(Class clazz) { try {/*from www.jav a 2 s . c o m*/ return java.net.URLDecoder.decode(getClassFile(clazz).getAbsolutePath(), "UTF-8"); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return ""; } } public static File getClassFile(Class clazz) { URL path = clazz.getResource(clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1) + ".classs"); if (path == null) { String name = clazz.getName().replaceAll("[.]", "/"); path = clazz.getResource("/" + name + ".class"); } return new File(path.getFile()); } }